• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ElggMemcache类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ElggMemcache的典型用法代码示例。如果您正苦于以下问题:PHP ElggMemcache类的具体用法?PHP ElggMemcache怎么用?PHP ElggMemcache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ElggMemcache类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: rowToElggStar

 /**
  * Create an Elgg* object from a given entity row.
  *
  * Handles loading all tables into the correct class.
  *
  * @param \stdClass $row The row of the entry in the entities table.
  *
  * @return \ElggEntity|false
  * @see get_entity_as_row()
  * @see add_subtype()
  * @see get_entity()
  * @access private
  *
  * @throws \ClassException|\InstallationException
  */
 function rowToElggStar($row)
 {
     if (!$row instanceof \stdClass) {
         return $row;
     }
     if (!isset($row->guid) || !isset($row->subtype)) {
         return $row;
     }
     $new_entity = false;
     // Create a memcache cache if we can
     static $newentity_cache;
     if (!$newentity_cache && is_memcache_available()) {
         $newentity_cache = new \ElggMemcache('new_entity_cache');
     }
     if ($newentity_cache) {
         $new_entity = $newentity_cache->load($row->guid);
     }
     if ($new_entity) {
         return $new_entity;
     }
     // load class for entity if one is registered
     $classname = get_subtype_class_from_id($row->subtype);
     if ($classname != "") {
         if (class_exists($classname)) {
             $new_entity = new $classname($row);
             if (!$new_entity instanceof \ElggEntity) {
                 $msg = $classname . " is not a " . '\\ElggEntity' . ".";
                 throw new \ClassException($msg);
             }
         } else {
             error_log("Class '" . $classname . "' was not found, missing plugin?");
         }
     }
     if (!$new_entity) {
         //@todo Make this into a function
         switch ($row->type) {
             case 'object':
                 $new_entity = new \ElggObject($row);
                 break;
             case 'user':
                 $new_entity = new \ElggUser($row);
                 break;
             case 'group':
                 $new_entity = new \ElggGroup($row);
                 break;
             case 'site':
                 $new_entity = new \ElggSite($row);
                 break;
             default:
                 $msg = "Entity type " . $row->type . " is not supported.";
                 throw new \InstallationException($msg);
         }
     }
     // Cache entity if we have a cache available
     if ($newentity_cache && $new_entity) {
         $newentity_cache->save($new_entity->guid, $new_entity);
     }
     return $new_entity;
 }
开发者ID:ibou77,项目名称:elgg,代码行数:74,代码来源:EntityTable.php


示例2: elasticsearch_entity_row_to_std

/**
 * Create a standard object from a given entity row.
 *
 * @param stdClass $row The row of the entry in the entities table.
 *
 * @return ElggEntity|false
 * @link http://docs.elgg.org/DataModel/Entities
 * @see get_entity_as_row()
 * @see add_subtype()
 * @see get_entity()
 * @access private
 *
 * @throws ClassException|InstallationException
 */
function elasticsearch_entity_row_to_std($row)
{
    if (!$row instanceof stdClass) {
        return $row;
    }
    if (!isset($row->guid) || !isset($row->subtype)) {
        return $row;
    }
    $new_entity = false;
    // Create a memcache cache if we can
    static $newentity_cache;
    if (!$newentity_cache && is_memcache_available()) {
        $newentity_cache = new ElggMemcache('new_entity_cache');
    }
    if ($newentity_cache) {
        $new_entity = $newentity_cache->load($row->guid);
    }
    if ($new_entity) {
        return $new_entity;
    }
    try {
        // load class for entity if one is registered
        $classname = get_subtype_class_from_id($row->subtype);
        if ($classname != "") {
            if (class_exists($classname)) {
                $new_entity = new $classname($row);
                if (!$new_entity instanceof ElggEntity) {
                    $msg = elgg_echo('ClassException:ClassnameNotClass', array($classname, 'ElggEntity'));
                    throw new ClassException($msg);
                }
            }
        }
        if (!$new_entity) {
            switch ($row->type) {
                case 'object':
                    $new_entity = new ElggObject($row);
                    break;
                case 'user':
                    $new_entity = new ElggUser($row);
                    break;
                case 'group':
                    $new_entity = new ElggGroup($row);
                    break;
                case 'site':
                    $new_entity = new ElggSite($row);
                    break;
                default:
                    $msg = elgg_echo('InstallationException:TypeNotSupported', array($row->type));
                    throw new InstallationException($msg);
            }
        }
    } catch (IncompleteEntityException $e) {
        return false;
    }
    return $new_entity;
}
开发者ID:pleio,项目名称:elasticsearch,代码行数:70,代码来源:functions.php


示例3: _elgg_invalidate_memcache_for_entity

/**
 * Invalidate an entity in memcache
 *
 * @param int $entity_guid The GUID of the entity to invalidate
 *
 * @return void
 * @access private
 */
function _elgg_invalidate_memcache_for_entity($entity_guid)
{
    static $newentity_cache;
    if (!$newentity_cache && is_memcache_available()) {
        $newentity_cache = new \ElggMemcache('new_entity_cache');
    }
    if ($newentity_cache) {
        $newentity_cache->delete($entity_guid);
    }
}
开发者ID:ibou77,项目名称:elgg,代码行数:18,代码来源:memcache.php


示例4: izap_update_metadata

/**
*function to update the metadata
*same as the update_metadata, only made metadata editable
*/
function izap_update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id)
{
    $id = (int) $id;
    if (!($md = elgg_get_metadata_from_id($id))) {
        return false;
    }
    // If memcached then we invalidate the cache for this entry
    static $metabyname_memcache;
    if (!$metabyname_memcache && is_memcache_available()) {
        $metabyname_memcache = new ElggMemcache('metabyname_memcache');
    }
    if ($metabyname_memcache) {
        $metabyname_memcache->delete("{$md->entity_guid}:{$md->name_id}");
    }
    $value_type = detect_extender_valuetype($value, sanitise_string(trim($value_type)));
    $owner_guid = (int) $owner_guid;
    if ($owner_guid == 0) {
        $owner_guid = elgg_get_logged_in_user_guid();
    }
    $access_id = (int) $access_id;
    // Support boolean types (as integers)
    if (is_bool($value)) {
        if ($value) {
            $value = 1;
        } else {
            $value = 0;
        }
    }
    // Add the metastring
    $value = elgg_get_metastring_id($value);
    if (!$value) {
        return false;
    }
    $name = elgg_get_metastring_id($name);
    if (!$name) {
        return false;
    }
    // If ok then add it
    $db_prefix = elgg_get_config('dbprefix');
    $result = update_data("UPDATE {$db_prefix}metadata set value_id='{$value}', value_type='{$value_type}', access_id={$access_id}, owner_guid={$owner_guid} where id={$id} and name_id='{$name}'");
    if ($result !== false) {
        $obj = elgg_get_metadata_from_id($id);
        if (elgg_trigger_event('update', 'metadata', $obj)) {
            return true;
        } else {
            elgg_delete_metadata(array('metadata_id' => $id));
        }
    }
    return $result;
}
开发者ID:Daltonmedia,项目名称:izap_profile_visitors,代码行数:54,代码来源:izap_profile_visitors_lib.php


示例5: set

 public function set($name, $value)
 {
     if (is_array($value)) {
         if (empty($value)) {
             $value = null;
         } else {
             $value = json_encode($value);
         }
     }
     if (parent::set($name, $value)) {
         $this->settings_cache[$name] = $value;
         // If memcache is available then delete this entry from the cache
         static $newentity_cache;
         if (!$newentity_cache && is_memcache_available()) {
             $newentity_cache = new ElggMemcache('new_entity_cache');
         }
         if ($newentity_cache) {
             $newentity_cache->delete($this->getGUID());
         }
     }
 }
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:21,代码来源:WidgetManagerWidget.php


示例6: delete_entity

/**
 * Delete an entity.
 *
 * Removes an entity and its metadata, annotations, relationships, river entries,
 * and private data.
 *
 * Optionally can remove entities contained and owned by $guid.
 *
 * @tip Use ElggEntity::delete() instead.
 *
 * @warning If deleting recursively, this bypasses ownership of items contained by
 * the entity.  That means that if the container_guid = $guid, the item will be deleted
 * regardless of who owns it.
 *
 * @param int  $guid      The guid of the entity to delete
 * @param bool $recursive If true (default) then all entities which are
 *                        owned or contained by $guid will also be deleted.
 *
 * @return bool
 * @access private
 */
function delete_entity($guid, $recursive = true)
{
    global $CONFIG, $ENTITY_CACHE;
    $guid = (int) $guid;
    if ($entity = get_entity($guid)) {
        if (elgg_trigger_event('delete', $entity->type, $entity)) {
            if ($entity->canEdit()) {
                // delete cache
                if (isset($ENTITY_CACHE[$guid])) {
                    invalidate_cache_for_entity($guid);
                }
                // If memcache is available then delete this entry from the cache
                static $newentity_cache;
                if (!$newentity_cache && is_memcache_available()) {
                    $newentity_cache = new ElggMemcache('new_entity_cache');
                }
                if ($newentity_cache) {
                    $newentity_cache->delete($guid);
                }
                // Delete contained owned and otherwise releated objects (depth first)
                if ($recursive) {
                    // Temporary token overriding access controls
                    // @todo Do this better.
                    static $__RECURSIVE_DELETE_TOKEN;
                    // Make it slightly harder to guess
                    $__RECURSIVE_DELETE_TOKEN = md5(elgg_get_logged_in_user_guid());
                    $entity_disable_override = access_get_show_hidden_status();
                    access_show_hidden_entities(true);
                    $ia = elgg_set_ignore_access(true);
                    $sub_entities = get_data("SELECT * from {$CONFIG->dbprefix}entities\n\t\t\t\t\t\tWHERE container_guid={$guid}\n\t\t\t\t\t\t\tor owner_guid={$guid}\n\t\t\t\t\t\t\tor site_guid={$guid}", 'entity_row_to_elggstar');
                    if ($sub_entities) {
                        foreach ($sub_entities as $e) {
                            // check for equality so that an entity that is its own
                            // owner or container does not cause infinite loop
                            if ($e->guid != $guid) {
                                $e->delete(true);
                            }
                        }
                    }
                    access_show_hidden_entities($entity_disable_override);
                    $__RECURSIVE_DELETE_TOKEN = null;
                    elgg_set_ignore_access($ia);
                }
                // Now delete the entity itself
                $entity->deleteMetadata();
                $entity->deleteOwnedMetadata();
                $entity->deleteAnnotations();
                $entity->deleteOwnedAnnotations();
                $entity->deleteRelationships();
                elgg_delete_river(array('subject_guid' => $guid));
                elgg_delete_river(array('object_guid' => $guid));
                remove_all_private_settings($guid);
                $res = delete_data("DELETE from {$CONFIG->dbprefix}entities where guid={$guid}");
                if ($res) {
                    $sub_table = "";
                    // Where appropriate delete the sub table
                    switch ($entity->type) {
                        case 'object':
                            $sub_table = $CONFIG->dbprefix . 'objects_entity';
                            break;
                        case 'user':
                            $sub_table = $CONFIG->dbprefix . 'users_entity';
                            break;
                        case 'group':
                            $sub_table = $CONFIG->dbprefix . 'groups_entity';
                            break;
                        case 'site':
                            $sub_table = $CONFIG->dbprefix . 'sites_entity';
                            break;
                    }
                    if ($sub_table) {
                        delete_data("DELETE from {$sub_table} where guid={$guid}");
                    }
                }
                return $res;
            }
        }
    }
    return false;
//.........这里部分代码省略.........
开发者ID:nachopavon,项目名称:Elgg,代码行数:101,代码来源:entities.php


示例7: delete_entity

/**
 * Delete an entity.
 *
 * Removes an entity and its metadata, annotations, relationships, river entries,
 * and private data.
 *
 * Optionally can remove entities contained and owned by $guid.
 *
 * @tip Use ElggEntity::delete() instead.
 *
 * @warning If deleting recursively, this bypasses ownership of items contained by
 * the entity.  That means that if the container_guid = $guid, the item will be deleted
 * regardless of who owns it.
 *
 * @param int  $guid      The guid of the entity to delete
 * @param bool $recursive If true (default) then all entities which are
 *                        owned or contained by $guid will also be deleted.
 *
 * @return bool
 * @access private
 */
function delete_entity($guid, $recursive = true)
{
    global $CONFIG, $ENTITY_CACHE;
    $guid = (int) $guid;
    if ($entity = get_entity($guid)) {
        if (elgg_trigger_event('delete', $entity->type, $entity)) {
            if ($entity->canEdit()) {
                // delete cache
                if (isset($ENTITY_CACHE[$guid])) {
                    _elgg_invalidate_cache_for_entity($guid);
                }
                // If memcache is available then delete this entry from the cache
                static $newentity_cache;
                if (!$newentity_cache && is_memcache_available()) {
                    $newentity_cache = new ElggMemcache('new_entity_cache');
                }
                if ($newentity_cache) {
                    $newentity_cache->delete($guid);
                }
                // Delete contained owned and otherwise releated objects (depth first)
                if ($recursive) {
                    // Temporary token overriding access controls
                    // @todo Do this better.
                    static $__RECURSIVE_DELETE_TOKEN;
                    // Make it slightly harder to guess
                    $__RECURSIVE_DELETE_TOKEN = md5(elgg_get_logged_in_user_guid());
                    $entity_disable_override = access_get_show_hidden_status();
                    access_show_hidden_entities(true);
                    $ia = elgg_set_ignore_access(true);
                    // @todo there was logic in the original code that ignored
                    // entities with owner or container guids of themselves.
                    // this should probably be prevented in ElggEntity instead of checked for here
                    $options = array("limit" => 0, "order_by" => false, "site_guids" => false);
                    foreach (array("site_guid", "container_guid", "owner_guid") as $column) {
                        $options['wheres'] = array("(({$column} = {$guid}) AND guid != {$guid})");
                        $batch = new ElggBatch('elgg_get_entities', $options);
                        $batch->setIncrementOffset(false);
                        foreach ($batch as $e) {
                            $e->delete(true);
                        }
                    }
                    access_show_hidden_entities($entity_disable_override);
                    $__RECURSIVE_DELETE_TOKEN = null;
                    elgg_set_ignore_access($ia);
                }
                // Now delete the entity itself
                $entity->deleteMetadata();
                $entity->deleteOwnedMetadata();
                $entity->deleteAnnotations();
                $entity->deleteOwnedAnnotations();
                $entity->deleteRelationships();
                elgg_delete_river(array('subject_guid' => $guid));
                elgg_delete_river(array('object_guid' => $guid));
                remove_all_private_settings($guid);
                $res = delete_data("DELETE from {$CONFIG->dbprefix}entities where guid={$guid}");
                if ($res) {
                    $sub_table = "";
                    // Where appropriate delete the sub table
                    switch ($entity->type) {
                        case 'object':
                            $sub_table = $CONFIG->dbprefix . 'objects_entity';
                            break;
                        case 'user':
                            $sub_table = $CONFIG->dbprefix . 'users_entity';
                            break;
                        case 'group':
                            $sub_table = $CONFIG->dbprefix . 'groups_entity';
                            break;
                        case 'site':
                            $sub_table = $CONFIG->dbprefix . 'sites_entity';
                            break;
                    }
                    if ($sub_table) {
                        delete_data("DELETE from {$sub_table} where guid={$guid}");
                    }
                }
                return (bool) $res;
            }
        }
//.........这里部分代码省略.........
开发者ID:pleio,项目名称:subsite_manager,代码行数:101,代码来源:entities.php


示例8: remove_user_admin

/**
 * Removes user $guid's admin flag.
 *
 * @param int $user_guid User GUID
 *
 * @return bool
 */
function remove_user_admin($user_guid)
{
    global $CONFIG;
    $user = get_entity((int) $user_guid);
    if ($user && $user instanceof ElggUser && $user->canEdit()) {
        if (elgg_trigger_event('remove_admin', 'user', $user)) {
            // invalidate memcache for this user
            static $newentity_cache;
            if (!$newentity_cache && is_memcache_available()) {
                $newentity_cache = new ElggMemcache('new_entity_cache');
            }
            if ($newentity_cache) {
                $newentity_cache->delete($user_guid);
            }
            $r = update_data("UPDATE {$CONFIG->dbprefix}users_entity set admin='no' where guid={$user_guid}");
            invalidate_cache_for_entity($user_guid);
            return $r;
        }
        return FALSE;
    }
    return FALSE;
}
开发者ID:riggo,项目名称:Elgg,代码行数:29,代码来源:users.php


示例9: update

 /**
  * Update a specific piece of metadata.
  *
  * @param int    $id         ID of the metadata to update
  * @param string $name       Metadata name
  * @param string $value      Metadata value
  * @param string $value_type Value type
  * @param int    $owner_guid Owner guid
  * @param int    $access_id  Access ID
  *
  * @return bool
  */
 function update($id, $name, $value, $value_type, $owner_guid, $access_id)
 {
     $id = (int) $id;
     if (!($md = $this->get($id))) {
         return false;
     }
     if (!$md->canEdit()) {
         return false;
     }
     // If memcached then we invalidate the cache for this entry
     static $metabyname_memcache;
     if (!$metabyname_memcache && is_memcache_available()) {
         $metabyname_memcache = new \ElggMemcache('metabyname_memcache');
     }
     if ($metabyname_memcache) {
         // @todo fix memcache (name_id is not a property of \ElggMetadata)
         $metabyname_memcache->delete("{$md->entity_guid}:{$md->name_id}");
     }
     $value_type = detect_extender_valuetype($value, $this->db->sanitizeString(trim($value_type)));
     $owner_guid = (int) $owner_guid;
     if ($owner_guid == 0) {
         $owner_guid = $this->session->getLoggedInUserGuid();
     }
     $access_id = (int) $access_id;
     // Support boolean types (as integers)
     if (is_bool($value)) {
         $value = (int) $value;
     }
     $value_id = $this->metastringsTable->getId($value);
     if (!$value_id) {
         return false;
     }
     $name_id = $this->metastringsTable->getId($name);
     if (!$name_id) {
         return false;
     }
     // If ok then add it
     $query = "UPDATE {$this->table}" . " set name_id='{$name_id}', value_id='{$value_id}', value_type='{$value_type}', access_id={$access_id}," . " owner_guid={$owner_guid} where id={$id}";
     $result = $this->db->updateData($query);
     if ($result !== false) {
         $this->cache->save($md->entity_guid, $name, $value);
         // @todo this event tells you the metadata has been updated, but does not
         // let you do anything about it. What is needed is a plugin hook before
         // the update that passes old and new values.
         $obj = $this->get($id);
         $this->events->trigger('update', 'metadata', $obj);
     }
     return $result;
 }
开发者ID:gzachos,项目名称:elgg_ellak,代码行数:61,代码来源:MetadataTable.php


示例10: get_metadata_byname

/**
 * Return the metadata values that match your query.
 * 
 * @param string $meta_name
 * @return mixed either a value, an array of ElggMetadata or false.
 */
function get_metadata_byname($entity_guid, $meta_name)
{
    global $CONFIG;
    $meta_name = get_metastring_id($meta_name);
    if (empty($meta_name)) {
        return false;
    }
    $entity_guid = (int) $entity_guid;
    $access = get_access_sql_suffix("e");
    $md_access = get_access_sql_suffix("m");
    // If memcache is available then cache this (cache only by name for now since this is the most common query)
    $meta = null;
    static $metabyname_memcache;
    if (!$metabyname_memcache && is_memcache_available()) {
        $metabyname_memcache = new ElggMemcache('metabyname_memcache');
    }
    if ($metabyname_memcache) {
        $meta = $metabyname_memcache->load("{$entity_guid}:{$meta_name}");
    }
    if ($meta) {
        return $meta;
    }
    $result = get_data("SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}metadata m JOIN {$CONFIG->dbprefix}entities e ON e.guid = m.entity_guid JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where m.entity_guid={$entity_guid} and m.name_id='{$meta_name}' and {$access} and {$md_access}", "row_to_elggmetadata");
    if (!$result) {
        return false;
    }
    // Cache if memcache available
    if ($metabyname_memcache) {
        if (count($result) == 1) {
            $r = $result[0];
        } else {
            $r = $result;
        }
        $metabyname_memcache->setDefaultExpiry(3600);
        // This is a bit of a hack - we shorten the expiry on object metadata so that it'll be gone in an hour. This means that deletions and more importantly updates will filter through eventually.
        $metabyname_memcache->save("{$entity_guid}:{$meta_name}", $r);
    }
    if (count($result) == 1) {
        return $result[0];
    }
    return $result;
}
开发者ID:eokyere,项目名称:elgg,代码行数:48,代码来源:metadata.php


示例11: garbagecollector_orphaned_metastrings

/**
 * Delete any orphaned entries in metastrings.
 *
 * @return void
 */
function garbagecollector_orphaned_metastrings()
{
    $dbprefix = elgg_get_config('dbprefix');
    // Garbage collect metastrings
    echo elgg_echo('garbagecollector:gc:metastrings');
    // If memcache is enabled then we need to flush it of deleted values
    if (is_memcache_available()) {
        $select_query = "\n\t\tSELECT * FROM {$dbprefix}metastrings WHERE\n\t\t(\n\t\t\t(id NOT IN (SELECT name_id FROM {$dbprefix}metadata)) AND\n\t\t\t(id NOT IN (SELECT value_id FROM {$dbprefix}metadata)) AND\n\t\t\t(id NOT IN (SELECT name_id FROM {$dbprefix}annotations)) AND\n\t\t\t(id NOT IN (SELECT value_id FROM {$dbprefix}annotations))\n\t\t)";
        $dead = get_data($select_query);
        if ($dead) {
            static $metastrings_memcache;
            if (!$metastrings_memcache) {
                $metastrings_memcache = new \ElggMemcache('metastrings_memcache');
            }
            foreach ($dead as $d) {
                $metastrings_memcache->delete($d->string);
            }
        }
    }
    $query = "\n\t\tDELETE FROM {$dbprefix}metastrings WHERE\n\t\t(\n\t\t\t(id NOT IN (SELECT name_id FROM {$dbprefix}metadata)) AND\n\t\t\t(id NOT IN (SELECT value_id FROM {$dbprefix}metadata)) AND\n\t\t\t(id NOT IN (SELECT name_id FROM {$dbprefix}annotations)) AND\n\t\t\t(id NOT IN (SELECT value_id FROM {$dbprefix}annotations))\n\t\t)";
    $result = delete_data($query);
    if ($result !== false) {
        echo elgg_echo('garbagecollector:ok');
    } else {
        echo elgg_echo('garbagecollector:error');
    }
}
开发者ID:thehereward,项目名称:Elgg,代码行数:32,代码来源:start.php


示例12: remove_all_private_settings

/**
 * Deletes all private settings for an entity.
 *
 * @param int $entity_guid The Entity GUID
 *
 * @return bool
 * @see get_private_setting()
 * @see get_all_private_settings()
 * @see set_private_setting()
 * @see remove_private_settings()
 * @link http://docs.elgg.org/DataModel/Entities/PrivateSettings
 */
function remove_all_private_settings($entity_guid)
{
    global $PRIVATE_SETTINGS_CACHE;
    static $private_setting_memcache;
    $dbprefix = elgg_get_config("dbprefix");
    $entity_guid = (int) $entity_guid;
    // check if you have access to the entity
    if (!get_entity_as_row($entity_guid)) {
        return false;
    }
    if (!isset($private_setting_memcache) && is_memcache_available()) {
        $private_setting_memcache = new ElggMemcache("private_settings");
    }
    $query = "DELETE FROM {$dbprefix}private_settings";
    $query .= " WHERE entity_guid = {$entity_guid}";
    $result = delete_data($query);
    if ($result !== false) {
        // unset local cache
        if (isset($PRIVATE_SETTINGS_CACHE[$entity_guid])) {
            unset($PRIVATE_SETTINGS_CACHE[$entity_guid]);
        }
        // unset memcache
        if ($private_setting_memcache) {
            // invalidate the settings in Memcache
            $private_setting_memcache->delete($entity_guid);
        }
    }
    return $result !== false;
}
开发者ID:pleio,项目名称:subsite_manager,代码行数:41,代码来源:private_settings.php


示例13: unsetAllSettings

 /**
  * Removes all settings for this plugin.
  *
  * @todo Should be a better way to do this without dropping to raw SQL.
  * @todo If we could namespace the plugin settings this would be cleaner.
  * @return bool
  */
 public function unsetAllSettings()
 {
     $db_prefix = get_config('dbprefix');
     $ps_prefix = elgg_namespace_plugin_private_setting('internal', '');
     $q = "DELETE FROM {$db_prefix}private_settings\n\t\t\tWHERE entity_guid = {$this->guid}\n\t\t\tAND name NOT LIKE '{$ps_prefix}%'\n\t\t\tAND name <> 'path'";
     $result = delete_data($q);
     // check memcache
     if ($result !== false && is_memcache_available()) {
         $private_setting_cache = new ElggMemcache("private_settings");
         // remove settings from memcache
         $private_setting_cache->delete($this->guid);
     }
     // unvalidate cache to reset to default behaviour
     elgg_invalidate_simplecache();
     return $result;
 }
开发者ID:pleio,项目名称:subsite_manager,代码行数:23,代码来源:SubsitePlugin.php


示例14: elgg_get_site_entity

<?php

$site = elgg_get_site_entity();
$key = "css_splash_" . $site->guid;
if (is_memcache_available()) {
    $cache = new ElggMemcache("rijkshuisstijl");
    $css = $cache->load($key);
    if ($css) {
        echo $css;
        return;
    }
}
$parser = new Less_Parser();
$parser->parseFile(RIJKSHUISSTIJL_LESS . "/splash.less", "/mod/rijkshuisstijl/src/assets/");
$colors = elgg_get_plugin_setting("colors", "rijkshuisstijl");
if ($colors) {
    $colors = unserialize($colors);
    foreach ($colors as $number => $value) {
        $parser->parse("@belastingdienst--{$number}: {$value};");
    }
}
$css = $parser->getCss();
echo $css;
if (is_memcache_available()) {
    $cache->save($key, $css, 0);
}
开发者ID:pleio,项目名称:rijkshuisstijl,代码行数:26,代码来源:splash.php


示例15: subsite_manager_plugin_action_hook

/**
 * The settings of a plugin have changed, check if we need to reset the cron cache file (only on subsites)
 *
 * @param string $hook
 * @param string $action => the action being called
 * @param unknown_type $return_value
 * @param unknown_type $params
 */
function subsite_manager_plugin_action_hook($hook, $action, $return_value, $params)
{
    // are we on a Subsite, so we can handle cron reset
    if (subsite_manager_on_subsite() && $action == "plugins/settings/save") {
        $site = elgg_get_site_entity();
        // handling of the cron cache reset is done by the event function
        subsite_manager_remove_cron_cache($site->getGUID());
    }
    // clear plugin order cache
    if (is_memcache_available()) {
        $memcache = new ElggMemcache('subsite_manager');
        $memcache->delete('plugin_order');
    }
}
开发者ID:pleio,项目名称:subsite_manager,代码行数:22,代码来源:hooks.php


示例16: delete_orphaned_metastrings

/**
 * Delete any orphaned entries in metastrings. This is run by the garbage collector.
 * 
 */
function delete_orphaned_metastrings()
{
    global $CONFIG;
    // If memcache is enabled then we need to flush it of deleted values
    if (is_memcache_available()) {
        $select_query = "\n\t\t\tSELECT * \n\t\t\tfrom {$CONFIG->dbprefix}metastrings where \n\t\t\t( \n\t\t\t\t(id not in (select name_id from {$CONFIG->dbprefix}metadata)) AND \n\t\t\t\t(id not in (select value_id from {$CONFIG->dbprefix}metadata)) AND \n\t\t\t\t(id not in (select name_id from {$CONFIG->dbprefix}annotations)) AND \n\t\t\t\t(id not in (select value_id from {$CONFIG->dbprefix}annotations))   \n\t\t\t)";
        $dead = get_data($select_query);
        if ($dead) {
            static $metastrings_memcache;
            if (!$metastrings_memcache) {
                $metastrings_memcache = new ElggMemcache('metastrings_memcache');
            }
            foreach ($dead as $d) {
                $metastrings_memcache->delete($d->string);
            }
        }
    }
    $query = "\n\t\t\tDELETE \n\t\t\tfrom {$CONFIG->dbprefix}metastrings where \n\t\t\t( \n\t\t\t\t(id not in (select name_id from {$CONFIG->dbprefix}metadata)) AND \n\t\t\t\t(id not in (select value_id from {$CONFIG->dbprefix}metadata)) AND \n\t\t\t\t(id not in (select name_id from {$CONFIG->dbprefix}annotations)) AND \n\t\t\t\t(id not in (select value_id from {$CONFIG->dbprefix}annotations))   \n\t\t\t)";
    return delete_data($query);
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:24,代码来源:metastrings.php


示例17: get_entity

/**
 * Loads and returns an entity object from a guid.
 *
 * @param int $guid The GUID of the entity
 *
 * @return ElggEntity The correct Elgg or custom object based upon entity type and subtype
 * @link http://docs.elgg.org/DataModel/Entities
 */
function get_entity($guid)
{
    static $newentity_cache;
    $new_entity = false;
    if (!is_numeric($guid)) {
        return FALSE;
    }
    if (!$newentity_cache && is_memcache_available()) {
        $newentity_cache = new ElggMemcache('new_entity_cache');
    }
    if ($newentity_cache) {
        $new_entity = $newentity_cache->load($guid);
    }
    if ($new_entity) {
        return $new_entity;
    }
    return entity_row_to_elggstar(get_entity_as_row($guid));
}
开发者ID:rasul,项目名称:Elgg,代码行数:26,代码来源:entities.php


示例18: elgg_delete_metastring_based_object_by_id

/**
 * Deletes a metastring-based object by its id
 *
 * @param int    $id   The object's ID
 * @param string $type The object's metastring type: annotation or metadata
 * @return bool
 *
 * @since 1.8.0
 * @access private
 */
function elgg_delete_metastring_based_object_by_id($id, $type)
{
    $id = (int) $id;
    $db_prefix = elgg_get_config('dbprefix');
    switch ($type) {
        case 'annotation':
        case 'annotations':
            $type = 'annotations';
            break;
        case 'metadata':
            $type = 'metadata';
            break;
        default:
            return false;
    }
    $obj = elgg_get_metastring_based_object_from_id($id, $type);
    $table = $db_prefix . $type;
    if ($obj) {
        // Tidy up if memcache is enabled.
        // @todo only metadata is supported
        if ($type == 'metadata') {
            static $metabyname_memcache;
            if (!$metabyname_memcache && is_memcache_available()) {
                $metabyname_memcache = new ElggMemcache('metabyname_memcache');
            }
            if ($metabyname_memcache) {
                $metabyname_memcache->delete("{$obj->entity_guid}:{$obj->name_id}");
            }
        }
        if ($obj->canEdit() && elgg_trigger_event('delete', $type, $obj)) {
            return delete_data("DELETE from {$table} where id={$id}");
        }
    }
    return false;
}
开发者ID:nachopavon,项目名称:Elgg,代码行数:45,代码来源:metastrings.php


示例19: removeAdmin

 /**
  * Removes user $guid's admin flag.
  *
  * @param int $user_guid User GUID
  *
  * @return bool
  */
 function removeAdmin($user_guid)
 {
     $user = get_entity((int) $user_guid);
     if ($user && $user instanceof \ElggUser && $user->canEdit()) {
         if (_elgg_services()->events->trigger('remove_admin', 'user', $user)) {
             // invalidate memcache for this user
             static $newentity_cache;
             if (!$newentity_cache && is_memcache_available()) {
                 $newentity_cache = new \ElggMemcache('new_entity_cache');
             }
             if ($newentity_cache) {
                 $newentity_cache->delete($user_guid);
             }
             $r = _elgg_services()->db->updateData("UPDATE {$this->CONFIG->dbprefix}users_entity set admin='no' where guid={$user_guid}");
             _elgg_invalidate_cache_for_entity($user_guid);
             return $r;
         }
         return false;
     }
     return false;
 }
开发者ID:gzachos,项目名称:elgg_ellak,代码行数:28,代码来源:UsersTable.php


示例20: datalist_set

/**
 * Set the value for a datalist element.
 *
 * @param string $name  The name of the datalist
 * @param string $value The new value
 *
 * @return bool
 * @access private
 */
function datalist_set($name, $value)
{
    global $CONFIG, $DATALIST_CACHE;
    // cannot store anything longer than 255 characters in db, so catch before we set
    if (elgg_strlen($name) > 255) {
        elgg_log("The name length for configuration variables cannot be greater than 255", "ERROR");
        return false;
    }
    $sanitised_name = sanitise_string($name);
    $sanitised_value = sanitise_string($value);
    // If memcache is available then invalidate the cached copy
    static $datalist_memcache;
    if (!$datalist_memcache && is_memcache_available()) {
        $datalist_memcache = new ElggMemcache('datalist_memcache');
    }
    if ($datalist_memcache) {
        $datalist_memcache->delete($name);
    }
    $success = insert_data("INSERT into {$CONFIG->dbprefix}datalists" . " set name = '{$sanitised_name}', value = '{$sanitised_value}'" . " ON DUPLICATE KEY UPDATE value='{$sanitised_value}'");
    if ($success !== FALSE) {
        $DATALIST_CACHE[$name] = $value;
        return true;
    } else {
        return false;
    }
}
开发者ID:duanhv,项目名称:mdg-social,代码行数:35,代码来源:configuration.php



注:本文中的ElggMemcache类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ElggMenuItem类代码示例发布时间:2022-05-23
下一篇:
PHP ElggGroup类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap