Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
80be69f
Fixed _keys duplicates during _load() (which came apparent in forEach…
fabien Jan 22, 2011
1ed10dc
Fixed duplicate keys (issue 17)
fabien Feb 28, 2011
0fb2660
fixing existing tests for current version of node
pathsny Apr 14, 2011
a3a6d26
removing keys array.
pathsny Apr 14, 2011
527e69d
added compacting ability
pathsny Apr 16, 2011
63d851a
tests for compacting behaviour
pathsny Apr 17, 2011
4799ef4
new test for compaction
pathsny Apr 17, 2011
4e8652a
added a compacting filter
pathsny Apr 17, 2011
ec17cc6
adding custom indexes
pathsny Apr 20, 2011
164ba1e
minor refactoring of indexs
pathsny Apr 21, 2011
ee5205f
documentation for indexes
pathsny Apr 21, 2011
93c8d08
added length and redundantLength
pathsny Apr 21, 2011
0e6fad4
documentation change
pathsny Apr 21, 2011
f5169c4
fixed bug which prevented multiple instances of Dirty
pathsny Apr 21, 2011
e508837
changed get to return a clone
pathsny Apr 25, 2011
34c985d
tests to keep clone
pathsny Apr 25, 2011
65af575
added a function to find all the values a particular index has
pathsny Sep 18, 2011
efe891a
bumping version
pathsny Sep 18, 2011
f80f5a5
Merge remote-tracking branch 'felixge/master'
pathsny May 12, 2013
ca53e83
updated dirty to the lastest version from the original repo
pathsny May 13, 2013
c711387
removing unnecessary line
pathsny May 13, 2013
a69cc64
bumping version
pathsny May 13, 2013
8d7988e
find returns clones now
pathsny May 13, 2013
a357b1b
fixing indexvalues and test
pathsny May 13, 2013
18c522a
indexes dont index empty values
pathsny May 23, 2013
cde7e5a
moved to multiple index values per index
pathsny May 23, 2013
f1b9e30
fixing bad test breaking other tests
pathsny May 24, 2013
357b240
get returns a deep clone which should allow fancy datastructures and …
pathsny May 24, 2013
16f473a
bumping version
pathsny May 24, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#EDITS

This is a fork of node-dirty with the following abilities added.

* A Compacting function
* Custom Indexes

# node-dirty

## Purpose
Expand Down Expand Up @@ -107,6 +114,47 @@ key once, even if it had been overwritten.

Emitted whenever all records have been written to disk.

### dirty.compact()

Compacts the database and gets rid of all redundant rows. It creates a new file to write to and then overwrites the existing file if it successfully writes it out. Use this when your system has some idle cycles. This should make load much faster.

### dirty.addCompactingFilter(filter)

Used while compacting the database and gets RID of any row that's matched by the filter (filter returns true). This is useful if you want to use the compacting run to clean up the database of stale data (like old database sessions). These filters are not persisted. You have to re-add them everytime the app starts.
filter is function(key, value);

### dirty event: 'compacted'

Emitted once compacting is complete if you start a compact run and succeeds.

### dirty event: 'compactingError'

Emitted once compacting is complete if you start a compact run and it fails. When this happens the in memory store will be inconsistent with the database on file. The memory store will no longer contain any rows that were filtered out by the compacting filter. But these rows will still be in the database. Ideally, since the filters are for removing stale rows that aren't harmful, this shouldn't matter.

### dirty.addIndex(index, indexFn)

Use this to add an index named index. indexFn is a function(key, val) that returns all the index values of that record. For example

dirty.addIndex('identifyingColor', function(k, v){
return [v.eyeColor, v.hairColor, v.skinColor];
});

You can add as many indexes as you want, but beware this adds to every add/delete/update operation an O(k) operation where k is the number of values which match a given index. If your index is not well distributed, with large databases you might face an issue. Don't worry about this most of the time.


### dirty.find(index, value)

This returns all documents with the given value for the index.

### dirty.length

This is a count of the number of documents. If compacting fails, this can become incorrect (since it will not be aware of filtered rows. It will reflect the memory store not the disk store.)

### dirty.redundantLength

This is a count of the number of redundant rows. You can use this to decide when to compact.˝


## Tests

[![Build Status](https://travis-ci.org/felixge/node-dirty.png)](https://travis-ci.org/felixge/node-dirty)
Expand Down
Loading