Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 2 files changed
  • 0 comments
  • 1 contributor

Showing 2 changed files with 27 additions and 22 deletions. Show diff stats Hide diff stats

  1. +22 16 README.rdoc
  2. +5 6 redis_array.gemspec
38 README.rdoc
Source Rendered
... ... @@ -1,4 +1,4 @@
1   -= redis_multi_list
  1 += redis_array
2 2
3 3 This library provides a way to store Ruby arrays in redis with *little* fuss. You're free to store anything that can be
4 4 converted to a string and other arrays that contain objects that can be converted into a string. Anything else will throw
@@ -6,42 +6,48 @@ an error because Redis only supports string storage. In addition, if you store a
6 6 be converted into a string, such as an integer, when you access the value it will be a string. A work-around will be
7 7 developed in the near future to support serialized objects and typecasting, though.
8 8
9   -redis_multi_list works by creating a list in redis for each array. Array keys are unique, so you cannot have multiple
  9 +redis_array works by creating a list in redis for each array. Array keys are unique, so you cannot have multiple
10 10 "test" keys, for example.
11 11
12 12 ```ruby
13   -list1 = RedisMultiList.get("list1") # Redis key will be redismultilist:list1
14   -list2 = RedisMultiList.get("list2") # Redis key will be redismultilist:list2
15   -list1.push list2 # The value of index 0 in the list redismultlist:list1 will be redismultilist:~>list2
16   -list1[0] # Will return a RedisMultiList::List object representing the values within redismultilist:list2
  13 +list1 = RedisArray.new("list1") # Redis key will be redisarray:list1
  14 +list2 = RedisMultiList.new("list2") # Redis key will be redisarray:list2
  15 +list1.push list2 # The value of index 0 in the list redisarray:list1 will be redisarray:~>list2
  16 +list1[0] # Will return a RedisArray object representing the values within redisarray:list2
17 17 ```
18 18
19 19 All retreival actions are done through Redis, so you don't have to worry about concurrency between processes when
20 20 accessing a List, or creating a different list instance using the same key.
21 21
22   -redis_multi_list attempts to act more like a Ruby Array then a Redis List. For example, LPOP in redis removes the first
23   -item within a list, whereas #pop on a RedisMultiList::List instance will remove the last.
  22 +redis_array attempts to act more like a Ruby Array then a Redis List. For example, LPOP in redis removes the first
  23 +item within a list, whereas #pop on a RedisArray instance will remove the last.
24 24
25 25 == Configuration
26 26
27   -redis_multi_list needs to have a redis connection to work properly. Where ever you open your Redis connection you should set it.
  27 +redis_array needs to have a redis connection to work properly. Where ever you open your Redis connection you should set it.
28 28 For example:
29 29
30 30 ```ruby
31 31 redis = Redis.new(ENV['OPENREDIS_URI'])
32   -RedisMultiList.redis = redis
  32 +RedisArray.redis = redis
33 33 ```
34 34
35   -redis_multi_list namespaces the arrays it stores. By default, it uses "redismultilist". Feel free to change it to
  35 +redis_array namespaces the arrays it stores. By default, it uses "redisarray". Feel free to change it to
36 36 whatever works and is unique.
37 37
38 38 == Usage
39 39
40   -Use RedisMultiList.get("list-name") to obtain a list. Use this whether the list already exists or not. Nothing will be
41   -added into redis until a value is pushed in. You can also call it without a list name, and a random one will be
42   -generated for you.
  40 +Use RedisArray.new("list-name") to create or obtain a list. If the list already exists in Redis this will not create
  41 +a new one; it will just access the existing. You can also use RedisArray.get("list-name"), which is just an alias for
  42 +new. Use this whether the list already exists or not. Nothing will be added into redis until a value is pushed in. You
  43 +can also call it without a list name, and a random one will be generated for you:
43 44
44   -Each RedisMultiList::List instance supports the following methods, which behave like the Ruby Array class, along
  45 +```
  46 +RedisArray.new
  47 +=> #<RedisArray:0x007fba4c4503b8 @key="e5f0dfbfa8fdcf2cef63f4ca6369a98c">
  48 +```
  49 +
  50 +Each RedisArray instance supports the following methods, which behave like the Ruby Array class, along
45 51 with including the Enumerable module: [], all, count, []=, <<, +, push, pop, delete_at, delete, and clear.
46 52
47 53 == Gotchas
@@ -53,7 +59,7 @@ until delete-by-index is supported using that method should be avoided. It's bet
53 59 Concatenating a List will append the rvalue to the list, rather then make a new one composed of the two values. This is
54 60 to maintain the key layout, but it is useful to add many items at once by providing them in an array.
55 61
56   -== Contributing to redis_multi_list
  62 +== Contributing to redis_array
57 63
58 64 * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
59 65 * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
11 redis_array.gemspec
@@ -4,7 +4,7 @@
4 4 # -*- encoding: utf-8 -*-
5 5
6 6 Gem::Specification.new do |s|
7   - s.name = "redis_multi_list"
  7 + s.name = "redis_array"
8 8 s.version = "0.1.0"
9 9
10 10 s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
@@ -25,13 +25,12 @@ Gem::Specification.new do |s|
25 25 "README.rdoc",
26 26 "Rakefile",
27 27 "VERSION",
28   - "lib/redis_multi_list.rb",
29   - "lib/redis_multi_list/list.rb",
30   - "spec/redis_multi_list/list_spec.rb",
31   - "spec/redis_multi_list_spec.rb",
  28 + "lib/redis_array.rb",
  29 + "redis_array.gemspec",
  30 + "spec/redis_array_spec.rb",
32 31 "spec/spec_helper.rb"
33 32 ]
34   - s.homepage = "http://github.com/byliner/redis_multi_list"
  33 + s.homepage = "http://github.com/byliner/redis_array"
35 34 s.licenses = ["MIT"]
36 35 s.require_paths = ["lib"]
37 36 s.rubygems_version = "1.8.24"

No commit comments for this range

Something went wrong with that request. Please try again.