Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Upgrade to 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Medvedev committed Dec 23, 2014
1 parent eaa2497 commit abe4177
Show file tree
Hide file tree
Showing 26 changed files with 445 additions and 509 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
vendor/
.idea/
pages/
composer.lock
pure.phar
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013 Medvedev Anton
Copyright (c) 2014 Medvedev Anton

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
72 changes: 23 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@ This is simple key-value storage written on PHP. It does not use files, or other
Via Composer:

```
composer require elfet/pure:~0.1
composer require elfet/pure
```

Via Phar file: [Download pure.phar](http://elfet.ru/purephp/pure.phar)

After downloading pure.phar run next commands:

```
mv pure.phar /usr/local/bin/pure
chmod +x /usr/local/bin/pure
```

You can update pure.phar by `pure update` command.

## Quick Guide
Start PurePHP by this command:

Expand All @@ -36,59 +25,53 @@ Now you can test PurePHP by simple commands like this:

```
> pure.queue.collection.push('hello')
bool(true)
> pure.queue.collection.push('world')
bool(true)
> pure.queue.collection.pop() ~ ' ' ~ pure.queue.collection.pop()
string(11) "hello world"
```

In pure console you can write commands on [Expression Language](https://github.com/symfony/expression-language). To exit from console type `exit` command.

To update PurePHP to latest version run command `pure update`.

## Documentation

### Connection to PurePHP server
```php
$port = 1337; // Default port value
$host = '127.0.0.1'; // Default host value
//...
$pure = new Pure\Clent($port, $host);
$pure = new Pure\Client($port, $host);
```

### Storages

PurePHP provide diffrent types on stogares. All supported storages are in [src/Storage](https://github.com/elfet/purephp/tree/master/src/Storage). You can access them by next methods and work with them like you work with them directly.
PurePHP provide different types on storages. All supported storages are in [src/Storage](https://github.com/elfet/purephp/tree/master/src/Storage). You can access them by next methods and work with them like you work with them directly.

Every storage has separate collection namespace. So you can have for different storages same collection names.
You do not need to manualy create any collection. They will be automatically create at first access.
You do not need to manually create any collection. They will be automatically create at first access.

```php
$pure->of('collection')->...
$pure->map('collection')->...
$pure->stack('collection')->...
$pure->queue('collection')->...
$pure->prioriry('collection')->...
$pure->lifetime('collection')->...
$pure->priority('collection')->...
```

Or you can access them by magic methods.

```php
$pure->of->collection->...
$pure->map->collection->...
$pure->stack->collection->...
$pure->queue->collection->...
//...
```

### Array Storage `->of`
### Array Storage `->map`

This is simple storage what uses php array to store your data.

To store date in collection use `push` method:
```php
$pure->of('collection')->push(['hello' => 'world']);
$pure->map('collection')->push(['hello' => 'world']);
```
Array Storage uses `array_merge` function.

To get value by key from collection use `get` method:
```php
Expand All @@ -98,44 +81,29 @@ $value = $pure->of('collection')->get('hello'); // will return 'world'.
To receive all elements use `all` method:
```php
$all = $pure->of('collection')->all();
```

To delete all elements use `clear` method:
```php
$all = $pure->of('collection')->clear();
```
``

You can check if key exist by `has` method, and delete element by `delete` method.

### Stack Storage `->stack`

This storage use `SplStack` to store your data.

You can use all `SplStack` methods and also `all`, `clear` methods.
You can use all `SplStack` methods and also `all` method.

### Queue Storage `->queue`

This storage use `SplQueue` to store your data.

You can use `SplQueue` methods and also `all`, `clear` methods.
You can use `SplQueue` methods and also `all` method.

`SplQueue` uses `enqueue` and `deenqueue` to push and pop from queue. In QueueStorage your can use `push` and `pop` methods to do this.

### Priority Queue Storage `->priority`

This storage use `SplPriorityQueue` to store your data.

You can use all `SplPriorityQueue` methods and also `all`, `clear` methods.

### Lifetime Storage `->lifetime`

In this storage you can store data which need to be deleted after some period. Life time in seconds.

```php
$pure->lifetime('collection')->set($key, $value, $lifetime);
```

You can get all elements by `all` method, check if key exist by `has` method, and delete element by `delete` method.
You can use all `SplPriorityQueue` methods and also `all` method.

### Filtering

Expand All @@ -154,13 +122,19 @@ $result = $pure->prioriry('collection')->filter('value > 100', 10);
$result = $pure->of('collection')->filter('value["year"] > 2000 and value["name"] matches "/term/"');
```

Filter rules writen on [Expression Language](https://github.com/symfony/expression-language) and cached on server.
In expression available two variables: key and value.
Filter rules uses [Expression Language](https://github.com/symfony/expression-language).
In expression available two variables: `key` and `value`.

### Deleting

You can delete storages by `delete` method:

```
$pure->delete('collection');
```

## TODO

* Unit Tests
* Dump to file
* Load from file
* Replication
Expand Down
50 changes: 0 additions & 50 deletions compile

This file was deleted.

12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Pure PHP key-value storage",
"authors": [
{
"name": "Elfet",
"name": "Anton Medvedev",
"email": "anton@elfet.ru"
}
],
Expand All @@ -14,13 +14,13 @@
},
"require": {
"react/react": "~0.4",
"symfony/console": "~2.4",
"symfony/expression-language": "~2.4",
"symfony/debug": "~2.4"
"symfony/console": "~2.6",
"symfony/expression-language": "~2.6",
"symfony/debug": "~2.6"
},
"require-dev": {
"symfony/finder": "~2.4",
"kherge/amend": "~3.0"
"symfony/finder": "~2.6",
"phpunit/phpunit": "~4.4"
},
"bin": ["pure"],
"license": "MIT",
Expand Down
8 changes: 0 additions & 8 deletions manifest.json

This file was deleted.

7 changes: 7 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<phpunit bootstrap="test/bootstrap.php">
<testsuites>
<testsuite name="Source">
<directory>test/</directory>
</testsuite>
</testsuites>
</phpunit>
14 changes: 3 additions & 11 deletions pure
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
#!/usr/bin/env php
<?php
require __DIR__ . '/vendor/autoload.php';

error_reporting(0);
Symfony\Component\Debug\ErrorHandler::register(false);

$console = new Symfony\Component\Console\Application('PurePHP', '0.2.1');

$console = new Symfony\Component\Console\Application('PurePHP', '1.0.0');
$console->add(new Pure\Console\StartCommand());
$console->add(new Pure\Console\ClientCommand());

$updateCommand = new KevinGH\Amend\Command('update');
$updateCommand->setDescription('Updates pure.phar to the latest version.');
$updateCommand->setManifestUri('https://raw.github.com/elfet/purephp/master/manifest.json');
$console->add($updateCommand);
$console->getHelperSet()->set(new KevinGH\Amend\Helper());

$console->run();
$console->run();
Loading

0 comments on commit abe4177

Please sign in to comment.