UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'esBM2dSGsqEVwoscBcX0rKVwylXWmAlVuZuTcKE4D4w='
WHERE
key_id = '9e3c6365e1e14d3bdd4f50cda8819c2a6ef943d96757b10f91fddb45df52a040'
AND (
token = 'esBM2dSGsqEVwoscBcX0rKVwylXWmAlVuZuTcKE4D4w='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)