Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 2353 Bytes
1 | = CachedModel |
2 | |
3 | Rubyforge Project: |
4 | |
5 | http://rubyforge.org/projects/rctools/ |
6 | |
7 | Documentation: |
8 | |
9 | http://dev.robotcoop.com/Libraries/cached_model/ |
10 | |
11 | == About |
12 | |
13 | CachedModel stores Rails ActiveRecord objects in memcache allowing for very |
14 | fast retrievals. CachedModel uses the ActiveRecord::Locking to ensure that |
15 | you don't perform multiple updates. |
16 | |
17 | == CachedModel Doesn't... |
18 | |
19 | CachedModel is not magic. |
20 | |
21 | CachedModel only accelerates simple finds for single rows. |
22 | |
23 | CachedModel won't cache every query you run. |
24 | |
25 | CachedModel isn't smart enough to determine the dependencies between your |
26 | queries so that it can accelerate more complicated queries. Without these |
27 | smarts you'll only end up with a broken application. |
28 | |
29 | If you want to cache more complicated queries you need do it by hand. |
30 | |
31 | == Using CachedModel |
32 | |
33 | First, install the cached_model gem: |
34 | |
35 | $ sudo gem install cached_model |
36 | |
37 | Then set up memcache-client for CachedModel by setting CACHE in your |
38 | config/environment files: |
39 | |
40 | CACHE = MemCache.new 'localhost:11211', :namespace => 'my_rails_app' |
41 | |
42 | You will need separate namespaces for production and development, if |
43 | you are using memcache on the same machine. |
44 | |
45 | Note that using memcache with tests will cause test failures, so set your |
46 | memcache to be readonly for the test environment. |
47 | |
48 | Then make Rails load the gem: |
49 | |
50 | $ tail -n 4 config/environment.rb |
51 | # Include your application configuration below |
52 | |
53 | require 'cached_model' |
54 | |
55 | Then edit your ActiveRecord model to inherit from CachedModel instead of |
56 | ActiveRecord::Base: |
57 | |
58 | $ head -n 8 app/models/photo.rb |
59 | ## |
60 | # A Photo from Flickr. |
61 | |
62 | class Photo < CachedModel |
63 | |
64 | belongs_to :point |
65 | belongs_to :route |
66 | |
67 | == Extra Features |
68 | |
69 | === Local Cache |
70 | |
71 | CachedModel also incorporates an in-process cache, but it is disabled by |
72 | default. In order to enable the in-process cache enable it in your |
73 | environment.rb: |
74 | |
75 | CachedModel.use_local_cache = true |
76 | |
77 | And add a after_filter that flushes the local cache: |
78 | |
79 | class ApplicationController < ActionController::Base |
80 | |
81 | after_filter { CachedModel.cache_reset } |
82 | |
83 | end |
84 | |
85 | IF YOU DO NOT ADD THE AFTER FILTER YOU WILL EXPERIENCE EXTREME PROCESS GROWTH. |
86 | |
87 | === Memcache |
88 | |
89 | Memcache may be disabled and the TTL for objects stored in memcache may be |
90 | changed: |
91 | |
92 | CachedModel.use_memcache = false |
93 | CachedModel.ttl = 86400 |
94 | |
95 | The default TTL for memcache objects is 900 seconds. |
96 |