Tephlon: Store and retrieve objects in files

Recommend this page to a friend!
  Info   Screenshots   View files (10)   Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
51%Total: 298 All time: 7,317 This week: 268
Version License PHP version Categories
tephlon 1.0MIT/X Consortium ...5.0PHP 5, Databases, Files and Folders, L..., D...
Description Author

This package can be used to store and retrieve objects in files or other storage container types:

It can serialize objects or other type of variable values and store them in files. It features:

- Java-style key-value maps
- Namespaces
- Codeigniter integration
- Configurable life time of records
- Multi-driver architecture (SQL, file system, etc, ...)
- Access to stored objects without using SQL
- Easy incremental backup of data with SVN/GIT

Picture of Simone Scarduzio
Name: Simone Scarduzio <contact>
Classes: 1 package by
Country: Italy Italy
Age: 37
All time rank: 3752153 in Italy Italy
Week rank: 771 36 in Italy Italy

:: Tephlon PHP Persistence library ::

For recent updates, documentation, examples, issue tracking and discussion please always refer to the following site:


Feel free to contact me if you are interested in improving this software.

== Install==
Typically this is the directory layout you want to keep in your Tephlon project:
                     |_> index.php
                     |_> css/
                     |_> img/
                     |_> Tephlon

== Direct Access Usage  Example==

// include somewhere Tephlon script appropriately.

// 1. Get a Tephlon persistent resource
$t = Tephlon::getResource();

// 2. Decide a label for your precious object and invoke it with retrieve
$my_precious = $t->retrieve("my_precious_label");

    If there was a cache record for "my_precious_label", now the variable $my_precious will
    have its content inside. If no such record was found, it's being created with value of null,
    and null is returned.


// You can also specify a fallback defaul value if the record is not found (optional)
// $my_precious = $t->retrieve("my_precious_label", array());

Doing as above is the same of doing:

$my_precious = $t->retrieve("my_precious_label");
if($myprecious != null){
    $my_precious = array();

// 3. Now you are free to modify your "precious" variable and make it become any type, from boolean to
// any class object. Once you want to save it to Tephlon persistence layer, simply do:

$my_precious = functionToCalculateImportantData($x, $y);
// Other business logic...

// 4. Saving to persistence!
$t->register($my_precious, "my_precious_label"); 

// Now the new value of my precious will be saved, so that next script execution (read: page visit) will have that
// content.

// You can also specify a lifetime (in seconds) for this record. For example:
// For example here, the content will be available for the next 24h
$t->register($my_precious, "my_precious_label", 24*60*60);

== Using TMap Data Structure ==
Note: refer to Twitter example and TMapTest.php for complete reference

TMap is a wrapper class against the core I/O API of Tephlon's persistence engine.
It works as Java's Map interface, implementing almost all methods: (get(key), put(key, value), clear(), 
values(), keys(), etc).
but also a new one, which makes sense in PHP: getAll() which returns all the content of the map as
 an associative array.
// 1. include somewhere Tephlon script appropriately.

// 2.a Initialize the TMap into global namespace.
$map = new TMap();
// Now if you already executed the script, the map will already contain keys and values!!!

// 2.b Initialize TMap specifying a namespace (some examples)
$map = new TMap("myUsers");
$map = new TMap("posts_from_user_" . $userID);
$map = new TMap("recent_comments");
// Now if you already executed the script, the map will already contain keys and values!!!

    NOTE: a namespace can set also passing an object, though this practice is quite risky
    since it can make your content unreachable if you do it wrong.

// 3. Put some  value (some examples)
$map->put("key1", "some_string");
$map->put(time(), new Post($userID, $content);

// 4. Modifying content of records
$map->put("key1", "this_string_is_better");

// 5. Retrieve it
$var = $map->get("key1");

$theUser = $map->get($requestedUser);
$map->put($requestedUser, $theUser);


  • Logo
File Role Description
config (1 file)
DataStructures (2 files)
lib (4 files)
LICENSE.txt Lic. MIT license
README.txt Doc. Install and use Tephlon
Tephlon.php Class Main class

  Files  /  config  
File Role Description
   tephlon_config.php Conf. Settings

  Files  /  DataStructures  
File Role Description
   TephlonType.php Class Data structure superclass
   TMap.php Class A data structure resembling Java's Map interface

  Files  /  lib  
File Role Description
   FileResource.php Class Driver for file based persistence
   Logger.php Class Logging utility
   PersistenceEngine.php Class Common operations for persistence
   Record.php Class Internal data type

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:7,317
This week:268
 User Ratings  
 All time

For more information send a message to info at phpclasses dot org.