README.md in looksist-0.2.5 vs README.md in looksist-0.2.6
- old
+ new
@@ -29,11 +29,11 @@
* Add an initializer to configure looksist
``` ruby
Looksist.configure do |looksist|
- looksist.lookup_store = Redis.new(:url => (ENV['REDIS_URL'], :driver => :hiredis)
+ looksist.lookup_store = Redis.new(:url => ENV['REDIS_URL'], :driver => :hiredis)
looksist.driver = Looksist::Serializers::Her
end
```
You need to specify the driver to manage the attributes. In this case, we use [HER](https://github.com/remiprev/her). You can add support for ActiveResource or ActiveRecord as needed (also refer to specs for free form usage without a driver).
@@ -43,11 +43,11 @@
it 'should generate declarative attributes on the model with simple lookup value' do
module SimpleLookup
class Employee
include Looksist
attr_accessor :id
- lookup :name, using= :id
+ lookup :name, using: :id
def initialize(id)
@id = id
end
end
@@ -56,23 +56,27 @@
expect(Looksist.lookup_store).to receive(:get).with('ids/1').and_return('Employee Name')
e = SimpleLookup::Employee.new(1)
expect(e.name).to eq('Employee Name')
end
```
-lookup takes the following form:
+lookup can take the following forms:
``` ruby
# will lookup "employees/#{employee_id}" from the store
-lookup :name, using = :employee_id
+lookup :name, using: :employee_id
# will lookup "stars/#{employee_id}" from the store
-lookup :name, using = :employee_id, bucket_name="stars"
+lookup :name, using: :employee_id, bucket_name: "stars"
# will lookup "stars/#{employee_id}" from the store
# for an object with two attributes (name, location)
-lookup [:name, :location], using = :employee_id
+lookup [:name, :location], using: :employee_id
+# will lookup "stars/#{employee_id}" from the store
+# for an object with two attributes (name, location) and expose name as nome
+lookup [:name, :age], using: :id, as: {name: 'nome'}
+
```
### With Plain Hashes
@@ -184,5 +188,19 @@
}
})
end
```
+### Controlling the L2 cache
+Looksist has support for an in memory L2 cache which it uses to optimize redis lookups. To disable L2 cache initialize looksists as below.
+
+* Note that in no L2 cache mode, all lookups would go to redis and the gem would not optimize redundant lookups.
+* Hash based lookups would still see optimizations which come from performing unique on keys when injecting values.
+
+```ruby
+Looksist.configure do |looksist|
+ looksist.lookup_store = Redis.new(:url => ENV['REDIS_URL'], :driver => :hiredis)
+ looksist.driver = Looksist::Serializers::Her
+ looksist.l2_cache = :no_cache
+end
+
+```