| Class | SQLite3FeedCache |
| In: |
sqlite3_feed_cache.rb
|
| Parent: | Object |
This is a transparent replacement for FeedTool’s DatabaseFeedCache. You set it up once at the start of your script/application, and then can safely forget about it.
# set up the cache
SQLite3FeedCache.set_db('./db/feeds.db')
FeedTools::configurations[:feed_cache] = SQLite3FeedCache
# start using FeedTools
feed = FeedTools::Feed.open('http://dekstop.de/weblog/index.xml')
See sqlite3_feed_cache.rb for a database schema.
| SQL_FIND_BY_ID | = | 'select id, href, title, link, feed_data, ' + 'feed_data_type, http_headers, last_retrieved ' + 'from cached_feeds where (id=?) order by id desc limit 1' | ||
| SQL_FIND_BY_HREF | = | 'select id, href, title, link, feed_data, ' + 'feed_data_type, http_headers, last_retrieved ' + 'from cached_feeds where (href=?) order by id desc limit 1' | ||
| SQL_INSERT_FEED | = | 'insert into cached_feeds (href, title, link, ' + 'feed_data, feed_data_type, http_headers, last_retrieved) values ' + '(?, ?, ?, ?, ?, ?, ?)' | ||
| SQL_UPDATE_FEED | = | 'update cached_feeds set href=?, title=?, link=?, ' + 'feed_data=?, feed_data_type=?, http_headers=?, last_retrieved=? ' + ' where id=?' |
| feed_data | [RW] | Required by FeedTools. |
| feed_data_type | [RW] | Required by FeedTools. |
| href | [RW] | Required by FeedTools. |
| http_headers | [RW] | Required by FeedTools. |
| id | [RW] | Required by FeedTools. |
| last_retrieved | [R] | Required by FeedTools. |
| link | [RW] | Required by FeedTools. |
| title | [RW] | Required by FeedTools. |
Required by FeedTools.
Currently always returns true.
TODO: implement this properly. At least check if we could establish a db connection
Required by FeedTools.
Find a cached feed by its URL. Returns an SQLite3FeedCache instance, or nil if no feed with this URL exists in the cache.
This is basically a static factory method using SQLite3FeedCache#load_by_href
Required by FeedTools.
Find a cached feed by its primary key. Returns an SQLite3FeedCache instance, or nil if no feed with this id exists in the cache.
This is basically a static factory method using SQLite3FeedCache#load_by_id
Required by FeedTools.
Currently does nothing.
TODO: implement this (and look up what we’re supposed to do here: establish a connection? Make sure that the table exists?)
Specify the SQLite3 database file used for caching. You need to call this first to set up the cache.
Set the number of times to retry writing to a busy database before giving up. This only has an effect on the save method.
Set the delay (in seconds) before retrying to write to a busy database. This only has an effect on the save method.
Required by FeedTools.
Takes a String or Time object. Strings will get converted to Time internally (and are being treated as if they describe a UTC time).
Attempt to load a cached feed by its URL. Returns self on success, or nil if no feed with this URL exists in the cache.
Attempt to load a cached feed by its primary key. Returns self on success, or nil if no feed with this id exists in the cache.
Required by FeedTools.
Returns true if this object has not been saved yet, i.e. if it is not yet stored in the cache database.