Class | Rufus::Cloche |
In: |
lib/rufus/cloche/version.rb
lib/rufus/cloche.rb |
Parent: | Object |
A cloche is a local JSON hashes store.
Warning : cloches are process-safe but not thread-safe.
VERSION | = | '1.0.4' |
WIN | = | (RUBY_PLATFORM.match(/mswin|mingw/) != nil) |
dir | [R] |
Creates a new ‘cloche’.
There are 2 options :
On the Windows platform, :nolock is set to true automatically.
Attempts at deleting a document. You have to pass the current version or at least the { ‘_id’ => i, ‘type’ => t, ‘_rev’ => r }.
Will return nil if the deletion is successful.
If the deletion failed because the given doc has an older revision number that the one currently stored, the doc in its freshest version will be returned.
Returns true if the deletion failed.
Given a type, this method will return an array of all the documents for that type.
A optional second parameter may be used to select, based on a regular expression, which documents to include (match on the key ‘_id’).
Will return an empty Hash if there is no documents for a given type.
:skip and :limit are understood (pagination).
If :count => true, the query will simply return the number of documents that matched.
Puts a document (Hash) under the cloche.
If the document is brand new, it will be given a revision number ‘_rev’ of 0.
If the document already exists in the cloche and the version to put has an older (different) revision number than the one currently stored, put will fail and return the current version of the doc.
If the put is successful, nil is returned.
Returns a sorted list of all the ids for a given type of documents.
Actually reads each file and returns the real _id list