Commit b20c1fb0 authored by Antoine Millet's avatar Antoine Millet
Browse files

[bug#3922] Updated object database to allow to give an infinite TTL to server defined tags.

parent 171e0102
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ class CCServer(object):
        for login in to_register:
            conf = self.conf.show(login)
            obj = TqlObject(id=login, r=conf['role'], a=login)
            self.objects.register(obj)
            self.objects.register(obj, cleanable=('ip', 'con'))

        for login in to_unregister:
            self.objects.unregister(login)
+9 −2
Original line number Diff line number Diff line
@@ -245,10 +245,15 @@ class ObjectsDB(object):
        '''
        return self._objects[oid]

    def register(self, obj):
    def register(self, obj, cleanable=()):
        '''
        Populate the database with the specified object. All the tags specified
        in the passed object will be declared as infite TTL.
        in the passed object are not declared in cache and will never be
        cleaned.

        :param obj: the object to register
        :param clenable: the optionnal list of tags to declare as cleanable when
            the cache is cleaned
        '''

        with self._lock:
@@ -258,6 +263,8 @@ class ObjectsDB(object):
                raise AlreadyRegistered('The object is already registered')
            else:
                self._objects[obj['id']] = obj
                for tag in cleanable:
                    self._ttls[(obj['id'], tag)] = datetime.max

    def unregister(self, obj_id):
        '''