Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
More information on how to use this module
  • Loading branch information
softbrix committed Dec 6, 2018
1 parent 65bfda3 commit 948cf30
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Readme.md
Expand Up @@ -3,24 +3,68 @@
# Stureby Index
This is an simple index or cache for javascript.

Install the module simply with npm or yarn

```
npm i --save stureby_index
```

or

```
yarn add stureby_index
```

Create the index instance by simply requiring the stureby_index module and create a
new instance of the object.

```
var shIndex = require('stureby_index');
const idx = shIndex(idxPath);
```

Then you can use the put, get and search methods to modify the index.

```
idx.put('as', 'the beste1');
idx.put('asa', 'the beste2');
idx.put('asas', 'the beste3');
idx.put('asasas', 'the beste4');
console.log(idx.get('asasas')) // 'the beste4'
```

The first argument to the put method is the key and the second is the value.
The same key can be linked to multiple values.

The search method will return a list of matched keys.

```
console.log(idx.search('asas')); // ['asas', 'asasas']
```

## Version 2
The new version is backwards compatible with version 1 of the index. The index
will be upgraded and once it is flushed back to disk the process is not reversible.

This version adds the following methods:

- toJSON()
- delete(key)
- clear()

### Don't persist on disk
In this version it is possible to create a index without the disk access. The
options parameter should include persist false which will use the noop_storage.

## Version 3

This version has an internal cache for the open indexes so if you try to access the same path from different parts
of the code in the same javascript vm you will write and read from a single instance.

This version adds the following methods:

- size()

## Flush before process exists
```
if(!_.isUndefined(process)) {
Expand Down

0 comments on commit 948cf30

Please sign in to comment.