Trees | Indices | Help |
---|
|
1 # 2 # Copyright (c) 2008--2016 Red Hat, Inc. 3 # 4 # This software is licensed to you under the GNU General Public License, 5 # version 2 (GPLv2). There is NO WARRANTY for this software, express or 6 # implied, including the implied warranties of MERCHANTABILITY or FITNESS 7 # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 8 # along with this software; if not, see 9 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 10 # 11 # Red Hat trademarks are not licensed under GPLv2. No permission is 12 # granted to use or replicate Red Hat trademarks that are incorporated 13 # in this software or its documentation. 14 # 15 # Mechanism to persistently cache sync info (mostly post-parsed(XML) 16 # package objects). 17 # 18 19 # system imports: 20 import os 21 22 # rhn imports: 23 from spacewalk.common import rhnCache 24 from spacewalk.common.rhnConfig import CFG, initCFG 25 from spacewalk.common.rhnLib import hash_object_id 26 27 # NOTE: this is a python 2.2-ism 28 __all__ = [] 29 3032 _compressed = 1 3358 59 64 6535 # Kind of kludgy - this may have weird side-effects if called from 36 # within the server code 37 rhnCache.CACHEDIR = CFG.SYNC_CACHE_DIR3840 # Get the key 41 key = self._get_key(object_id) 42 return rhnCache.get(key, modified=timestamp, raw=0, 43 compressed=self._compressed)4446 # Get the key 47 key = self._get_key(object_id) 48 return rhnCache.set(key, value, modified=timestamp, raw=0, 49 compressed=self._compressed)5052 # Get the key 53 key = self._get_key(object_id) 54 return rhnCache.has_key(key, modified=timestamp)5567 _subdir = "__unknown__" 6872 73 77 7870 hash_val = hash_object_id(object_id, 2) 71 return os.path.join("satsync", self._subdir, hash_val, str(object_id))80 _subdir = "packages"81 8284 _subdir = "source-packages"85 8688 _subdir = "errata" 8993 94 101 102 if __name__ == '__main__': 103 initCFG("server.satellite") 104 c = PackageCache() 105 pid = 'package-12345' 106 c.cache_set(pid, {'a': 1, 'b': 2}) 107 print(c.cache_get(pid)) 10891 hash_val = hash_object_id(object_id, 1) 92 return os.path.join("satsync", self._subdir, hash_val, str(object_id))
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Wed Mar 4 07:37:43 2020 | http://epydoc.sourceforge.net |