socketref,再见!高德

https://github.com/adoggie

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  246 Posts :: 4 Stories :: 312 Comments :: 0 Trackbacks

常用链接

留言簿(54)

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜

TileCache默认是Disk缓存Tile数据,存储和检索的效率远不及数据库,所以要开发数据库Cache,读完TileCache代码,发现其系统结构设计的还算可以
tilecache-2.10\TileCache\Caches目录下就是TileCache自带的Cache类型,Cache有个抽象基类,我的数据Cache只要实现这些Cache的接口便能完成到数据库的Tile存取。

 1 class Cache (object):
 2     def __init__ (self, timeout = 30.0, stale_interval = 300.0, readonly = False, **kwargs):
 3         self.stale    = float(stale_interval)
 4         self.timeout = float(timeout)
 5         self.readonly = readonly
 6                 
 7     def lock (self, tile, blocking = True):
 8         start_time = time.time()
 9         result = self.attemptLock(tile)
10         if result:
11             return True
12         elif not blocking:
13             return False
14         while result is not True:
15             if time.time() - start_time > self.timeout:
16                 raise Exception("You appear to have a stuck lock. You may wish to remove the lock named:\n%s" % self.getLockName(tile)) 
17             time.sleep(0.25)
18             result = self.attemptLock(tile)
19         return True
20 
21     def getLockName (self, tile):
22         return self.getKey(tile) + ".lck"
23 
24     def getKey (self, tile):
25         raise NotImplementedError()
26 
27     def attemptLock (self, tile):
28         raise NotImplementedError()
29 
30     def unlock (self, tile):
31         raise NotImplementedError()
32 
33     def get (self, tile):
34         raise NotImplementedError()
35 
36     def set (self, tile, data):
37         raise NotImplementedError()
38     
39     def delete(self, tile):
40         raise NotImplementedError()
接口够简单了吧 ,最主要的实现的 是get,set,getKey这3个主要接口
tilecache.cfg的Cache.type设置为DB_POSTGRES




posted on 2010-04-14 23:47 放屁阿狗 阅读(4478) 评论(0)  编辑 收藏 引用 所属分类: MapGisOpenSource开源工程WebGis

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理