root/cpsskins/branches/paris-sprint-2006/caching.py

Revision 3388, 1.3 kB (checked in by jmorliaguet, 2 years ago)

- misc fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 ##############################################################################
2 #
3 # Copyright (c) 2005-2006 Nuxeo and Contributors.
4 # All Rights Reserved.
5 #
6 # This software is subject to the provisions of the Zope Public License,
7 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11 # FOR A PARTICULAR PURPOSE.
12 #
13 ##############################################################################
14 """
15
16 $Id$
17 """
18 __docformat__ = "reStructuredText"
19
20 from zope.app.cache.interfaces.ram import IRAMCache
21 from zope.app.cache.ram import RAMCache
22 from zope.component.factory import Factory
23 from zope.interface import implements
24
25 cache = RAMCache()
26 IMAGE_CACHE_ID = 'images'
27
28 class IImageCache(IRAMCache):
29
30     def get(key, default):
31         """ """
32
33     def __setitem__(key, value):
34         """ """
35
36 class ImageCache(RAMCache):
37
38     implements(IImageCache)
39
40     def get(self, key, default=None):
41         return cache.query(IMAGE_CACHE_ID, {'key': key}, default)
42
43     def __setitem__(self, key, value):
44         cache.set(value, IMAGE_CACHE_ID, {'key': key})
45
46 ImageCacheFactory = Factory(ImageCache)
Note: See TracBrowser for help on using the browser.