Hatena::Grouprubyist

yuisekiのいまさらruby厨日記

2010-10-02

PStoreをJSONで

15:06 | はてなブックマーク - PStoreをJSONで - yuisekiのいまさらruby厨日記

いろんなサービスのAPI結果などをキャッシュする的な用途を想定

require 'rubygems'
require 'sinatra'
require 'json/pure'
require 'pstore'
require 'active_support'
class JsonStore < PStore
  def initialize(file); super(file); end
  def dump(table); table.to_json; end
  def load(content); JSON.load(content); end
end
db = JsonStore.new('json.dat')
helpers do
  def db_init(db, service, user)
    db[service] = Hash.new unless db[service]
    db[service][user] = Hash.new unless db[service][user]
    db[service][user]["updated_at"] = Time.now.to_i-3600 unless db[service][user]["updated_at"]
    return db[service][user]
  end
end

DuniyoDuniyo 2012/05/25 17:18 :Выходит ошибка в верхней части страници:Notice: Undefined index: gbloal_character_set in /home/domains/***/public_html/yarss.php on line 181Notice: Undefined index: gbloal_character_set in /home/domains/***/public_html/yarss.php on line 191CРїncok pa3pewehhbx k nhaekcaunn oopymob b RSS: (opml)И такие крякозабры внизуTeРїepb bb moxete aobabntb xenaembe Рїotokn b Rhaekc.Nonck Рїo bnoram.как можно это исправить?

bqbuqibqbuqi 2012/05/26 05:43 83vAPB <a href="http://afkgmhlwxndv.com/">afkgmhlwxndv</a>

pbfypveszbkpbfypveszbk 2012/05/28 22:49 6x4gE0 , [url=http://pklythccqmwr.com/]pklythccqmwr[/url], [link=http://ghkguxosxzjn.com/]ghkguxosxzjn[/link], http://qagkqsqpbvxk.com/

ゲスト



トラックバック - http://rubyist.g.hatena.ne.jp/yuiseki/20101002