def set_object(model, instance, fields=None, engine_name=None):
    from uliweb import settings
    
    if not check_enable():
        return
    
    redis = get_redis()
    if not redis: return
    
    tablename = model._alias or model.tablename
    exclude = []
    if not fields:
        fields, exclude = get_fields(tablename)
    
    v = instance.dump(fields, exclude=exclude)
    info = settings.get_var('OBJCACHE_TABLES/%s' % tablename, {})
    
    if info is None:
        return
    
    expire = settings.get_var('OBJCACHE/timeout', 0)
    key = 'id'
    if info and isinstance(info, dict):
        expire = info.get('expire', expire)
        key = info.get('key', key)
    
    if '.' in key or key not in model.properties:
        _key = import_attr(key)(instance)
    else:
        _key = getattr(instance, key)
    _id = get_id(engine_name or model.get_engine_name(), tablename, _key)
    try:
        pipe = redis.pipeline()
        p = pipe.delete(_id).hmset(_id, v)
        expire_msg = ''
        if expire:
            p = p.expire(_id, expire)
            expire_msg = ':expire=%d' % expire
        r = p.execute()
        log.debug("Saving to cache objcache:set:table=%s:id=[%s]:%s" % (tablename, _id, expire_msg))
    except Exception as e:
        log.exception(e)
Initial Setup
dataset/ETHPy150Open limodou/uliweb/uliweb/contrib/objcache/__init__.py/set_object--crossover with--dataset/ETHPy150Open treeio/treeio/treeio/core/administration/api/tests.py/CoreAPITest.setUp