An open API service indexing awesome lists of open source software.

https://github.com/nextapps-de/flexicache


https://github.com/nextapps-de/flexicache

Last synced: 9 months ago
JSON representation

Awesome Lists containing this project

README

          

# FlexiCache

### Lightweight auto-balancing cache handler with zero dependencies.

FlexiCache automatically balance caches by expiration time, frequency of data accesses, access timeout, maximum stack size and/or memory limit.

Supported Platforms:
- Browser
- Node.js

Supported Module Definitions:
- AMD (RequireJS, Xone)
- CommonJS (Node.js)
- Closure (Xone)
- Global (window)

All Features:


  • Auto-cleanup cache by:

    • Expiration time

    • Frequency of data accesses

    • Access timeout

    • Maximum size (stack)

    • Memory limit



  • Allows free combination of all the above options

  • Debug infos & statistics

  • Save / Load dump

Optional Plugins: (actually unreleased)


  • Redis API Adapter

  • Filesystem Plugin (HTML5)

  • Filesystem Plugin (Node.js)

  • LocalStorage Plugin (HTML5)

## Installation

##### HTML / Javascript

```html

...
```

##### Node.js

```npm
npm install flexicache
```

In your code include as follows:

```javascript
var FlexiCache = require("flexicache");
```

Or pass in options when requiring:

```javascript
var cache = require("flexicache").create({/* options */});
```

__AMD__

```javascript
var FlexiCache = require("./flexicache.js");
```

## Usage (API)

#### Create a new cache

```js
var cache = new FlexiCache();
```

alternatively you can also use:

```js
var cache = FlexiCache.create();
```

##### Create a new cache with custom options

> FlexiCache.__create__(options)

```js
var cache = new FlexiCache({

// default values:

expire: 60 * 60 * 1000, // 1 hour
size: 1000,
auto: true,
timeout: false,
memory: false
});
```

#### Add items to a cache

> Cache.__add___(id, *)

```js
cache.add(10000, 'foo');
```
add more complex objects:
```js
cache.add(10025, {

id: 10025,
name: 'foo'
});
```
clone and add objects:
```js
cache.add(10025, {

id: 10025,
name: 'foo'

}, true);
```

#### Update item of the cache

> Cache.__update__(id, *)

```js
cache.update(10000, 'bar');
```
clone and update objects:
```js
cache.update(10025, {

id: 10025,
name: 'foo'

}, true);
```

#### Remove item to the cache

> Cache.__remove__(id)

```js
cache.remove(10025);
```

#### Destroy the cache

```js
cache.destroy();
```

#### Initialize the cache

> Cache.__init__(options)

```js
cache.init();
```

#### Get info

```js
cache.info();
```

Returns information about the cache, e.g.:

```json
{
"bytes": 3600356288,
"id": 0,
"auto": false,
"expire": 3600,
"size": 10000,
"status": false
}
```

#### Optimize / Cleanup cache

```js
cache.cleanup();
```

---
Author FlexiCache: Thomas Wilkerling

License: Apache 2.0 License