twilio/BankersBox được TopGit xếp vào nhóm dự án mã nguồn mở, với 571 sao trên GitHub, viết chủ yếu bằng CoffeeScript. redis-like wrapper for javascript storage
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
A redis-like wrapper for javascript data storage using localStorage as
the default persistent data-store.
Motivation
Modern browsers provide a native javascript localStorage object
which acts as a simple client-side key-value store per
origin. Currently, storage is limited to 5MB and can only store
strings as values (integers, floats, and booleans are coerced into
strings upon save).
Redis is an insanely popular key-value server on
steroids. It provides many more capabilities than just simple key-value
storage.
BankersBox aims to bring redis-like APIs and behavior to the
client-side using localStorage as the default data backing
mechanism. You can store strings, arrays, and javscript objects in
BankersBox. Behind the scenes, BankersBox transparently uses
JSON.stringify and JSON.parse to save and restore non-string values to
their original types.
BankersBox uses a pluggable storage adapter system so that other
methods may be used to persist and restore data other than with
localStorage. See the Storage Adapters section below.
BankersBox is not a redis client. It is only meant to be a
storage abstraction with redis-like APIs and behaviors for those
familiar with the redis way. If you are looking for a javascript redis
client (e.g. for use with node.js) please turn back now.
Usage
Like redis, BankersBox has the concept of "databases" which are just
stores with different index numbers. BankersBox takes the id of the
store you wish to use in the constructor. Each id maps to a different
store, so if you set "foo" in two separate stores, they will retain
their separate values.
In redis, key-value values must also be strings, but with BankersBox you can also store numbers, booleans, arrays, and objects.
When dealing with operations that involve numeric values (incr, decr, etc) the values should be numbers (duh).
LISTS
Values stored in lists can also be strings, numbers, booleans, arrays, and objects.
SETS
Values stored in sets should be strings. When storing arrays or objects in sets, the behavior is undefined.
Implemented Functions
KEYS
keys
del
exists
type
STRINGS
append
decr
decrby
incr
incrby
get
getset
set
setnx
strlen
HASHES
none, see TODO.md
LISTS
lindex
llen
lpop
lpush
lpushx
lrange
lrem
lset
ltrim
rpop
rpoplpush
rpush
rpushx
SETS
sadd
scard
sismember
smembers
smove
spop
srandmember
srem
SORTED SETS (ZSET)
none, see TODO.md
CONNECTION
select
Storage Adapters
By default, BankersBox will use localStorage to persist data between sessions.
The main bankersbox.js file comes with two adapters built in:
BankersBoxLocalStorageAdapter - default adapter for using localStorage
BankersBoxNullAdapter - adapter which does not persist or restore data anywhere, good for testing
To specify your desired storage adapter, pass it into the constructor in the options hash:
bb = new BankersBox(1, {adapter: new BankersBoxNullAdapter()});
To create your own adapter, you must create an object which has the following three functions:
storeItem(key, value)
stores a value in the data-store associated with a key
param: key - a string
param: value - a string
returns: void
getItem(key)
retrieves a value from the data-store for the associated key
param: key - a string
returns: string - the value represented by key
removeItem(key)
deletes the value in the data-store associated with the key
param: key - a string
returns: void
If you create your own adapters, please add appropriate unit tests
following the examples in the tests/adapter_*.test.coffee files.
API Usage
BankersBox has tried to adhere as closely as possible to the Redis
command API and return values associated with each command.
You can read the full Redis Command Documentation.
In the cases where Redis would normally return a nil value,
BankersBox will return the javascript null value. In the cases
where Redis would return an error, BankersBox will throw a
BankersBoxException or BankersBoxKeyException depending on
the situation.
Usage On Your Webpage
Simply copy bankersbox.js (or bankersbox.min.js if you have minified)
to your site's static assets folder and link to it inside your page
source:
BankersBox depends on using a global JSON object which must provide
parse and stringify functions. Make sure to include a JSON
library in the page as well or BankersBox will throw an exception when
you try to instantiate.
Development
To develop on BankersBox, simply hack on bankersbox.js.
To install the node modules needed for testing, simply:
npm install
Testing
BankersBox has a large suite of unit tests. If you add new
functionality, please update (or add) the appropriate
tests/bb_*.test.coffee file with new tests. You can run the unit tests
with:
make test
Minify
BankersBox is minified using the Google Closure javascript compression tool. This is handled in the Makefile with:
make min
This will output bankersbox.min.js. To test the minified version as well, simply:
twilio/BankersBox có 571 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/twilio/BankersBox. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
twilio/BankersBox có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho twilio/BankersBox. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
twilio/BankersBox còn đang phát triển không?
Commit gần nhất trên twilio/BankersBox là 3.6 năm trước (theo timestamp GitHub). Repo có 31 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
twilio/BankersBox là gì?
twilio/BankersBox (twilio/BankersBox) là dự án CoffeeScript trên GitHub. Theo mô tả gốc: redis-like wrapper for javascript storage
twilio/BankersBox viết bằng ngôn ngữ gì?
twilio/BankersBox chủ yếu viết bằng CoffeeScript. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về BankersBox?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về BankersBox.