UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'fKugv3EMhXIZ0zRmRecJO9GpSFrSmznaXMujzq+pun8='
WHERE
key_id = '789142c712ae0d02d2b89f37fde276c70d6f349c5f9d5fec0580a541c78fe9d5'
AND (
token = 'fKugv3EMhXIZ0zRmRecJO9GpSFrSmznaXMujzq+pun8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)