You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by devinbost <de...@gmail.com> on 2019/11/14 23:24:16 UTC

How do we delete caches?

When we create a new table via SQL, it creates the cache for the table (as
expected). However, if we drop the table, the cache is not deleted. We can't
figure out how to delete the cache. So, we have many caches accumulating
that we can't delete but can't use for SQL because we've deleted their
tables.

How do we delete caches? 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

RE: Re: How do we delete caches?

Posted by Alexandr Shapkin <le...@gmail.com>.
> How do we delete caches?



What about DROP TABLE [1]? This should remove both a table and a cache.



> Is there a way to run the SQL query that doesn't require us to first get or

create an existing cache



You can use a thin client for that, please, review the
[JDBC](https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/sql/SqlJdbcExample.java)
example.

With this approach, the default schema would be PUBLIC.



> which results in two caches, only one of which is deleted when we drop the
table.

Ignite allows you to use a single cache for multiple tables, but we do not
recommend this approach.



You can set your schema manually using cache API with
SqlQuery.setSchema("PUBLIC") [2]



[1] - <https://apacheignite-sql.readme.io/docs/drop-table>

[2] - [https://apacheignite-sql.readme.io/docs/schema-and-indexes#section-
overview](https://apacheignite-sql.readme.io/docs/schema-and-indexes#section-
overview)





 **From:**[devinbost](mailto:devin.bost@gmail.com)  
 **Sent:** Friday, November 15, 2019 2:55 AM  
 **To:**[user@ignite.apache.org](mailto:user@ignite.apache.org)  
 **Subject:** Re: How do we delete caches?



devinbost wrote

> When we create a new table via SQL, it creates the cache for the table (as

> expected). However, if we drop the table, the cache is not deleted. We

> can't

> figure out how to delete the cache. So, we have many caches accumulating

> that we can't delete but can't use for SQL because we've deleted their

> tables.

>

> How do we delete caches?

>

> \--

> Sent from: http://apache-ignite-users.70518.x6.nabble.com/



For example, to run a SQL script to create a table, we can run:

clientCache = ignite.getOrCreateCache(tableName);

clientCache.query(IgniteHelpers.createFieldsQuery("sql/createExampleTable.sql")).getAll();



Is there a way to run the SQL query that doesn't require us to first get or

create an existing cache? If we run the two lines above, it takes the cache

name and uses it for the Table's schema name and then creates another cache

in the form of SQL_<CACHE_NAME>_<TABLE_NAME>, which results in two caches,

only one of which is deleted when we drop the table.







\--

Sent from: http://apache-ignite-users.70518.x6.nabble.com/




Re: How do we delete caches?

Posted by devinbost <de...@gmail.com>.
devinbost wrote
> When we create a new table via SQL, it creates the cache for the table (as
> expected). However, if we drop the table, the cache is not deleted. We
> can't
> figure out how to delete the cache. So, we have many caches accumulating
> that we can't delete but can't use for SQL because we've deleted their
> tables.
> 
> How do we delete caches? 
> 
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/

For example, to run a SQL script to create a table, we can run:
    clientCache = ignite.getOrCreateCache(tableName);
   
clientCache.query(IgniteHelpers.createFieldsQuery("sql/createExampleTable.sql")).getAll();

Is there a way to run the SQL query that doesn't require us to first get or
create an existing cache? If we run the two lines above, it takes the cache
name and uses it for the Table's schema name and then creates another cache
in the form of SQL_<CACHE_NAME>_<TABLE_NAME>, which results in two caches,
only one of which is deleted when we drop the table. 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/