| Home | Trees | Indices | Help |
|
|---|
|
|
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 # 4 # __init__.py 5 # 6 # Copyright 2010 Pablo Alejandro Costesich <pcostesi@alu.itba.edu.ar> 7 # 8 # Redistribution and use in source and binary forms, with or without 9 # modification, are permitted provided that the following conditions are 10 # met: 11 # 12 # * Redistributions of source code must retain the above copyright 13 # notice, this list of conditions and the following disclaimer. 14 # * Redistributions in binary form must reproduce the above 15 # copyright notice, this list of conditions and the following disclaimer 16 # in the documentation and/or other materials provided with the 17 # distribution. 18 # * Neither the name of the Dev Team nor the names of its 19 # contributors may be used to endorse or promote products derived from 20 # this software without specific prior written permission. 21 # 22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 # 34 35 """ 36 Memory decorator and utilites to speed up access to computationally expensive 37 functions. 38 """ 39 40 import random, time 41 from memtools.protocols import Memory 42 43 44 # 45 # AUXILIARY CLASSES 46 # 47 4850 """ Empty class used to differenciate None from unsetted values in k-v 51 storages that return None in both cases, like python-memcached. 52 """ 53 pass54 55 58 5961 '''This is a mock class. Forget it.''' 62 689470 self._client.__setitem__(key, value)7173 return self._client.__getitem__(key)7476 self._client.__delitem__(key)7779 a = [] 80 for i in self._client.keys(): 81 if i.startswith(string[:-1]): 82 a.append(i) 83 return a8486 while True: 87 rand = random.uniform(1, 3600) 88 time.sleep(rand) 89 try: 90 del self._client[self._client.keys()[int(random.uniform(0, 91 len(self._client)))]] 92 except: 93 pass
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Thu Apr 22 14:33:20 2010 | http://epydoc.sourceforge.net |