@@ -94,7 +94,7 @@ protected function driverConnect(): bool
9494 }
9595 $ url .= $ clientConfig ->getHost ();
9696 $ url .= ": {$ clientConfig ->getPort ()}" ;
97- $ url .= $ clientConfig -> getPath ();
97+ $ url .= ' / ' . $ this -> getDatabaseName ();
9898
9999 $ this ->instance = CouchDBClient::create (
100100 [
@@ -122,11 +122,16 @@ protected function getDatabaseName(): string
122122 */
123123 protected function createDatabase ()
124124 {
125- if (!in_array ($ this ->instance -> getDatabase (), $ this ->instance ->getAllDatabases (), true )) {
126- $ this ->instance ->createDatabase ($ this ->instance -> getDatabase ());
125+ if (!in_array ($ this ->getDatabaseName (), $ this ->instance ->getAllDatabases (), true )) {
126+ $ this ->instance ->createDatabase ($ this ->getDatabaseName ());
127127 }
128128 }
129129
130+ protected function getCouchDbItemKey (CacheItemInterface $ item )
131+ {
132+ return 'pfc_ ' . $ item ->getEncodedKey ();
133+ }
134+
130135 /**
131136 * @param CacheItemInterface $item
132137 * @return null|array
@@ -135,7 +140,7 @@ protected function createDatabase()
135140 protected function driverRead (CacheItemInterface $ item )
136141 {
137142 try {
138- $ response = $ this ->instance ->findDocument ($ item -> getEncodedKey ( ));
143+ $ response = $ this ->instance ->findDocument ($ this -> getCouchDbItemKey ( $ item ));
139144 } catch (CouchDBException $ e ) {
140145 throw new PhpfastcacheDriverException ('Got error while trying to get a document: ' . $ e ->getMessage (), 0 , $ e );
141146 }
@@ -166,8 +171,8 @@ protected function driverWrite(CacheItemInterface $item): bool
166171 try {
167172 $ this ->instance ->putDocument (
168173 ['data ' => $ this ->encode ($ this ->driverPreWrap ($ item ))],
169- $ item -> getEncodedKey ( ),
170- $ this ->getLatestDocumentRevision ($ item -> getEncodedKey ( ))
174+ $ this -> getCouchDbItemKey ( $ item ),
175+ $ this ->getLatestDocumentRevision ($ this -> getCouchDbItemKey ( $ item ))
171176 );
172177 } catch (CouchDBException $ e ) {
173178 throw new PhpfastcacheDriverException ('Got error while trying to upsert a document: ' . $ e ->getMessage (), 0 , $ e );
@@ -217,7 +222,7 @@ protected function driverDelete(CacheItemInterface $item): bool
217222 */
218223 if ($ item instanceof Item) {
219224 try {
220- $ this ->instance ->deleteDocument ($ item -> getEncodedKey ( ), $ this ->getLatestDocumentRevision ($ item -> getEncodedKey ( )));
225+ $ this ->instance ->deleteDocument ($ this -> getCouchDbItemKey ( $ item ), $ this ->getLatestDocumentRevision ($ this -> getCouchDbItemKey ( $ item )));
221226 } catch (CouchDBException $ e ) {
222227 throw new PhpfastcacheDriverException ('Got error while trying to delete a document: ' . $ e ->getMessage (), 0 , $ e );
223228 }
0 commit comments