-
Notifications
You must be signed in to change notification settings - Fork 0
Use MySQL as a key-value store
License
yegct/mysql_kv
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
# Example usage Set a string value: MysqlKv::write('hello', 'world') MysqlKv::read('hello') Set an integer: MysqlKv::write('int', 123) MysqlKv::read('int') Set a boolean: MysqlKv::write('bool', true) MysqlKv::read('bool') Fetch a value, and set it if not already set: MysqlKv::fetch('fetchable') { 'value' } Set an expiring value: MysqlKv::write('expiring', 123, :expires_in => 1.second) Old keys will automatically be expired when retrieved from the database. If you would like to expire them without retrieving them, try: MysqlKv::expire Increment a key: MysqlKv::incr('my_incr', 2) # => 2 MysqlKv::incr('my_incr', 1) # => 3 Note that if the value is not currently an integer, it will be destroyed and then created as an int. MysqlKv::write('my_incr', 'string') # => string MysqlKv::incr('my_incr', 1) # => 1 Delete a key: MysqlKv::write('deleteable', 'value') MysqlKv::delete('deleteable') Delete keys by prefix: [*1..9].each { |prefix| MysqlKv::write("prefix_#{prefix}", true) } MysqlKv::delete_starts_with('prefix_')
About
Use MySQL as a key-value store
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published