flutter_cs_cache

Flutter package to provide simple and extendible cache feature to be used in flutter applications.

Getting Started

Import CsCache as


Once imported make sure you have created CsCache instance ahead of time, before using getKey or setKey functions

### To set a key value
csCache.setKey(key: keyName, value: valueString, expireOn: expiryTimeInMillisecondsSinceEpoch);

### To get a key value
csCache.getKey(key: keyName);

### To remove a key value
csCache.removeKey(key: keyName);

### To purge all keys which might have been expired
csCache.purgeCache();

### To clear all cache entrie (expired and non-expired)
csCache.clearCache();


## example code

class _MyHomePageState extends State { String cacheMessage = ""; final CsCache cache = new CsCache(); final String _cacheKey = "1111";

void _checkCache() { String cacheEntry = cache.getKey(key: _cacheKey); if(cacheEntry == null) cache.setKey(key: _cacheKey, value: DateTime.now().toString(), expireOn: DateTime.now().add(new Duration(seconds: 300)).millisecondsSinceEpoch); setState(() { cacheMessage = cacheEntry ?? "Cache entry not found"; }); }

void _removeCacheEntry(){ cache.removeKey(key: _cacheKey); _checkCache(); }

@override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text(widget.title), ), body: new Center( child: new Column( mainAxisAlignment: MainAxisAlignment.center, children: [ new Text( 'Cache has following value:', style: Theme.of(context).textTheme.title, ), new Text( '$cacheMessage', style: Theme.of(context).textTheme.body1, ),

        SizedBox(height: 50.0,),
        RaisedButton(
          child: Text("Remove Cache Entry"),
          onPressed: _removeCacheEntry,
          )
      ],
    ),
  ),
  floatingActionButton: new FloatingActionButton(
    onPressed: _checkCache,
    tooltip: 'Add cache entry',
    child: new Icon(Icons.add),
  ), // This trailing comma makes auto-formatting nicer for build methods.
);

} }

Libraries

flutter_cs_cache

Dart

dart:ui
Built-in types and core primitives for a Flutter application. [...]

Core

dart:async
Support for asynchronous programming, with classes such as Future and Stream. [...]
dart:collection
Classes and utilities that supplement the collection support in dart:core. [...]
dart:convert
Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
dart:core
Built-in types, collections, and other core functionality for every Dart program. [...]
dart:developer
Interact with developer tools such as the debugger and inspector. [...]
dart:math
Mathematical constants and functions, plus a random number generator. [...]
dart:typed_data
Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]

VM

dart:io
File, socket, HTTP, and other I/O support for non-web applications. [...]
dart:isolate
Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]