Back to index

d-push  2.0
Public Member Functions | Protected Attributes | Private Attributes
HierarchyCache Class Reference
Inheritance diagram for HierarchyCache:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 HierarchyCache ()
 Constructor of the HierarchyCache.
 IsStateChanged ()
 Indicates if the cache was changed.
 CopyOldState ()
 Copy current CacheById to memory.
 GetFolder ($serverid, $oldState=false)
 Returns the SyncFolder object for a folder id If $oldstate is set, then the data from the previous state is returned.
 AddFolder ($folder)
 Adds a folder to the HierarchyCache.
 DelFolder ($serverid)
 Removes a folder to the HierarchyCache.
 ImportFolders ($folders)
 Imports a folder array to the HierarchyCache.
 ExportFolders ($oldstate=false)
 Exports all folders from the HierarchyCache.
 GetDeletedFolders ()
 Returns all folder objects which were deleted in this operation.
 GetStat ()
 Returns some statistics about the HierarchyCache.
 __sleep ()
 Returns objects which should be persistent called before serialization.

Protected Attributes

 $cacheById

Private Attributes

 $changed = false
 $cacheByIdOld

Detailed Description

Definition at line 45 of file hierarchycache.php.


Member Function Documentation

Returns objects which should be persistent called before serialization.

public

Returns:
array

Definition at line 210 of file hierarchycache.php.

                              {
        return array("cacheById");
    }

Adds a folder to the HierarchyCache.

Parameters:
SyncObject$folderpublic
Returns:
boolean

Definition at line 111 of file hierarchycache.php.

                                       {
        ZLog::Write(LOGLEVEL_DEBUG, "HierarchyCache: AddFolder() serverid: {$folder->serverid} displayname: {$folder->displayname}");

        // on update the $folder does most of the times not contain a type
        // we copy the value in this case to the new $folder object
        if (isset($this->cacheById[$folder->serverid]) && (!isset($folder->type) || $folder->type == false) && isset($this->cacheById[$folder->serverid]->type)) {
            $folder->type = $this->cacheById[$folder->serverid]->type;
            ZLog::Write(LOGLEVEL_DEBUG, sprintf("HierarchyCache: AddFolder() is an update: used type '%s' from old object", $folder->type));
        }

        // add/update
        $this->cacheById[$folder->serverid] = $folder;
        $this->changed = true;

        return true;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Copy current CacheById to memory.

public

Returns:
boolean

Definition at line 78 of file hierarchycache.php.

                                   {
        $this->cacheByIdOld = $this->cacheById;
        return true;
    }
HierarchyCache::DelFolder ( serverid)

Removes a folder to the HierarchyCache.

Parameters:
string$serveridid of folder to be removed

public

Returns:
boolean

Definition at line 136 of file hierarchycache.php.

                                         {
        $ftype = $this->GetFolder($serverid);

        ZLog::Write(LOGLEVEL_DEBUG, sprintf("HierarchyCache: DelFolder() serverid: '%s' - type: '%s'", $serverid, $ftype->type));
        unset($this->cacheById[$serverid]);
        $this->changed = true;
        return true;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

HierarchyCache::ExportFolders ( oldstate = false)

Exports all folders from the HierarchyCache.

Parameters:
boolean$oldstate(optional) by default false

public

Returns:
array

Definition at line 175 of file hierarchycache.php.

                                                     {
        if ($oldstate === false)
            return $this->cacheById;
        else
            return $this->cacheByIdOld;
    }

Here is the caller graph for this function:

Returns all folder objects which were deleted in this operation.

public

Returns:
array with SyncFolder objects

Definition at line 188 of file hierarchycache.php.

                                        {
        // diffing the OldCacheById with CacheById we know if folders were deleted
        return array_diff_key($this->cacheByIdOld, $this->cacheById);
    }

Here is the caller graph for this function:

HierarchyCache::GetFolder ( serverid,
oldState = false 
)

Returns the SyncFolder object for a folder id If $oldstate is set, then the data from the previous state is returned.

Parameters:
string$serverid
boolean$oldstate(optional) by default false

public

Returns:
SyncObject/boolean false if not found

Definition at line 93 of file hierarchycache.php.

                                                            {
        if (!$oldState && array_key_exists($serverid, $this->cacheById)) {
            return $this->cacheById[$serverid];
        }
        else if ($oldState && array_key_exists($serverid, $this->cacheByIdOld)) {
            return $this->cacheByIdOld[$serverid];
        }
        return false;
    }

Here is the caller graph for this function:

Returns some statistics about the HierarchyCache.

public

Returns:
string

Definition at line 199 of file hierarchycache.php.

                              {
        return sprintf("HierarchyCache is %s - Cached objects: %d", ((isset($this->cacheById))?"up":"down"), ((isset($this->cacheById))?count($this->cacheById):"0"));
    }

Constructor of the HierarchyCache.

public

Returns:

Definition at line 56 of file hierarchycache.php.

                                     {
        $this->cacheById = array();
        $this->cacheByIdOld = $this->cacheById;
        $this->changed = true;
    }

Here is the caller graph for this function:

Imports a folder array to the HierarchyCache.

Parameters:
array$foldersfolders to the HierarchyCache

public

Returns:
boolean

Definition at line 153 of file hierarchycache.php.

                                            {
        if (!is_array($folders))
            return false;

        $this->cacheById = array();

        foreach ($folders as $folder) {
            if (!isset($folder->type))
                continue;
            $this->AddFolder($folder);
        }
        return true;
    }

Here is the call graph for this function:

Indicates if the cache was changed.

public

Returns:
boolean

Definition at line 68 of file hierarchycache.php.

                                     {
        return $this->changed;
    }

Member Data Documentation

Definition at line 47 of file hierarchycache.php.

Definition at line 48 of file hierarchycache.php.

HierarchyCache::$changed = false [private]

Definition at line 46 of file hierarchycache.php.


The documentation for this class was generated from the following file: