UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'xD0TP5ZL49WvEOhZ9nb/5CkOz9CrU/lB9uOecuGaAr0='
WHERE
key_id = '166ee9831fbad61e4ee99a289b8695fb62bf4ade72c1fa3c5152a71e5bd336ac'
AND (
token = 'xD0TP5ZL49WvEOhZ9nb/5CkOz9CrU/lB9uOecuGaAr0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)