UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'dKW+yR9qao6pyeP2UFBeIJKze4FwJPYeKyhcGxvTSIU='
WHERE
key_id = 'a8f9c86fb9a09a64693277d94f49b492f66b706a22ce3e4ad77c8094d313f4da'
AND (
token = 'dKW+yR9qao6pyeP2UFBeIJKze4FwJPYeKyhcGxvTSIU='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)